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

查看:200
本文介绍了如何301重定向所有网页上的新域相同的页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我感动我的网站从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/

I'm moving my site from old-domain.com to new-domain.com with exactly the same pages, e.g., if old-domain.com has a page1.html (i.e., old-domain.com/page1.html) then the new domain has the same page, i.e., new-domain.com/page1.html

I tried this in the .htaccess file:

RewriteEngine on
RewriteRule (.*) http://new-domain.com/$1 [R=301,L] 

But only while old-domain.com will redirect to new-domain.com, old-domain.com/page1.html will not redirect to new-domain.com/page1.html

Thanks!

解决方案

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !newdomain.com$ [NC]
RewriteRule ^(.*)$ http://newdomain.com/$1 [L,R=301]

See here for more solutions: http://enarion.net/web/htaccess/migrate-domains/

这篇关于如何301重定向所有网页上的新域相同的页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆