我一直在扯我的头发。我想重定向所有的流量到我的新网站。
为了论证起见,新的站点是mysite.org。然而,有某些网页和规则和文件夹,我想重定向到新的网站-如果用户不访问这些文件夹或规则-它应该是一个通用的重定向到我的网站?
redirect 301 / http://example.org
redirect 301 /index.php http://example.org
redirect 301 /index.html http://example.org
redirect 301 /contact.php http://example.org/contact-us
redirect 301 /store-locator/list.php http://example.org/store-locator
redirect 301 /store-locator/ http://example.org/store-locator
redirect 301 /about.php http://example.org/about-us
redirect 301 /customer-care.php http://example.org/contact-us
redirect 301 /hq-location.php http://example.org/store-locator
redirect 301 /privacy.php http://example.org/privacy
redirect 301 /terms.php http://example.org/terms
redirect 301 /policy.php http://example.org/returns发布于 2015-07-28 06:21:26
您最好使用RedirectMatch而不是Redirect,因为RedirectMatch使用regex并且只匹配匹配的URI,而Redirect匹配任何以提供的模式开始的URI,因此您的第一个规则将始终执行,使得所有后续规则都无效。
RedirectMatch 301 ^/$ http://example.org
RedirectMatch 301 ^/index\.(html|php)$ http://example.org
RedirectMatch 301 ^/contact\.php$ http://example.org/contact-us
RedirectMatch 301 ^/store-locator/list\.php$ http://example.org/store-locator
RedirectMatch 301 ^/store-locator/?$ http://example.org/store-locator
RedirectMatch 301 ^/about\.php$ http://example.org/about-us
RedirectMatch 301 ^/customer-care\.php$ http://example.org/contact-us
RedirectMatch 301 ^/hq-location\.php$ http://example.org/store-locator
RedirectMatch 301 ^/privacy\.php$ http://example.org/privacy
RedirectMatch 301 ^/terms\.php$ http://example.org/terms
RedirectMatch 301 ^/policy\.php$ http://example.org/returns请确保在清除浏览器缓存后对其进行测试。
https://stackoverflow.com/questions/31668669
复制相似问题