【问题标题】:301 Redirect for all pages to new site Except 1 directory301 将所有页面重定向到新站点 除了 1 个目录
【发布时间】:2013-05-19 16:35:49
【问题描述】:

我正在尝试为除一个目录之外的所有页面创建一个 301 重定向到一个新站点,但我无法设置它。

这基本上是我需要的:

http://www.example.com/store => no redirects, users remain on http://www.example.com/store
http://www.example.com/* => all other pages go to this url http://www.newdomain.com/

AKA

http://www.example.com/apple => http://www.newdomain.com/
http://www.example.com/pie => http://www.newdomain.com/
http://www.example.com/foo/bar => http://www.newdomain.com/

我试过这个方法:

RewriteEngine on
RewriteCond %{REQUEST_URI}!^/store/
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]

但是当我转到http://www.example.com/store 时,我会转到http://www.newdomain.com/store

基本上我需要目录 /store 保留在旧域上。任何人都可以帮忙吗?不熟悉 .htaccess 规则...

【问题讨论】:

    标签: apache .htaccess http-redirect


    【解决方案1】:
    RewriteEngine on
    RewriteCond %{REQUEST_URI} !^/store
    RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]
    

    【讨论】:

    • 不应该出现的空间的经典案例。谢谢!
    猜你喜欢
    • 2013-06-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-08
    • 2016-06-07
    • 2015-09-03
    • 2011-01-05
    相关资源
    最近更新 更多