如何301重定向所有网页上的新域相同的页面(How to 301 redirect all pages to the same pages on new domain)

   IT问题网   2019-07-01 00:00:00

问 题

我感动我的网站从old-domain.com到new-domain.com一模一样的网页,例如,如果old-domain.com有page1.html(即old-domain.com/page1 html的),那么新域具有相同的页面,即new-domain.com/page1.html

我在.htaccess文件中尝试过这样的:

rewriteengine叙述上
重写规则(。*)http://new-domain.com/$1 [r = 301,l]
 

但是,只有当old-domain.com会重定向到new-domain.com,old-domain.com/page1.html的不会重定向到new-domain.com/page1.html

谢谢!

解决方案
rewriteengine叙述上
的rewritebase /
的rewritecond%{http_host}!newdomain.com $ [nc]
重写规则^(。*)$ http://newdomain.com/$1 [l,r = 301]
 

在这里看到更多的解决方案:<一href="http://enarion.net/web/htaccess/migrate-domains/">http://enarion.net/web/htaccess/migrate-domains/

标签:如何定向所有网页相同页面



分享:

  • 微信
  • QQ好友
  • QQ空间
  • 新浪微博


热门推荐

codeIgniter |从的.htaccess删除网址的index.php(CodeIgniter | .htaccess removing index.php from url)

problem ok, i did exactly as asked in the documentation o ...

htaccess的作品在本地主机,但在EC2实例不工作(htaccess works in localhost but doesn&#39;t work in EC2 instance)

problem my htaccess file works on localhost b ...

使用CGI和Bottle.py路由的URL问题(Problems with Routing URLs using CGI and Bottle.py)

problem i've been having difficulty getting anything more ...

如何将需要使用的.htaccess的所有文件,密码除了一个?(How would I require a password for all files except one using .htaccess)

problem i have a new website i'm working on that the clie ...

如何更改使用在GoDaddy的Linux主机.htacess文件中的PHP文件扩展名?(How to change the PHP file extension using .htacess file on GoDaddy Linux Hosting)

problem i am using the following .htacess rul ...

使用.htaccess文件与哈希重定向URL(Redirect URL with hash using .htaccess file)

problem i'm trying to redirect a url containi ...

使用的.htaccess与php5.4内置的服务器(use .htaccess with php5.4 built-in server)

problem in my development environment, i use ...

亚马逊S3和.htaccess(Amazon S3 and .htaccess)

problem i have a site (made in iweb) that i am hosting on ...

htaccess的搜索引擎优化Googlebot抓取没有hashbangs单页的应用(.htaccess for SEO bots crawling single page applications without hashbangs)

problem using a pushstate enabled page, normally you redi ...

Symfony的:电子邮件地址作为请求参数(Symfony: email address as request parameter)

problem i'm having some issues with passing an email addr ...

阿帕奇的.htaccess要求用户身份验证之前重定向到HTTPS(Apache .htaccess redirect to HTTPS before asking for user authentication)

problem this is my .htaccess: rewriteengine on rewriteco ...

无论是使用的.htaccess或php.ini文件更改PHP版本的服务器(Change PHP version on server using either .htaccess or php.ini)

problem how can i change the php version to 5 ...

强制HTTPS为整个服务器/域(Force https for entire server/domain)

problem i am developing a number of forms which should on ...

htaccess的密码保护,但不能在本地主机(htaccess password protect but not on localhost)

problem i have set up a dev site and want to password pro ...

Laravel 4虚拟主机和国防部重写设置(Laravel 4 Virtual Host and mod rewrite setup)

problem i've been trying for a few hours to install larav ...

多长时间采取的.htaccess更改生效?(How long does it take for .htaccess changes to take effect)

problem i have added url rewrite rules to my ...

如何显示Apache默认的404页在PHP(How to display Apache&#39;s default 404 page in PHP)

problem i have a webapp that needs to process the uri to ...

添加注释为.htaccess(Adding comments to .htaccess)

problem why does this work: rewriterule (.+) ...

如何正则表达式和.htaccess重写URL(How to REGEX and .htaccess rewrite url)

problem i have this url and i need to grab th ...

重定向子域名,并保留URL结构(redirect subdomain and retain url structure)

problem i'm redirecting a wordpress blog that ...