我想使用htaccess将某些页面重定向到另一个域中的等效页面,其他页面重定向到主页。
像那样:
http://old-domain.com/certain-page
重定向到: http://new-domain.com/certain-page
http://old-domain.com/another-certain-page
重定向到: http://new-domain.com/another-certain-page
仅将这些页面重定向,否则,必须将页面重定向到新的域主页。
http://old-domain.com/non-certain-page
重定向到: http://new-domain.com
这是我的尝试:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^certain-page$ http://new-domain.com/certain-page [R=301,L]
RewriteRule ^another-certain-page$ http://new-domain.com/another-certain-page [R=301,L]
</IfModule>
但是不知道如何排除其他页面。
这里有什么帮助吗?
提前致谢!
我不确定你是什么意思
但是不知道如何排除其他页面
但是,当您为页面创建特定规则时,已经将它们排除在外了。这应该工作。
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#redirect specific pages
RewriteRule ^certain-page$ http://new-domain.com/certain-page [R=301,L]
RewriteRule ^another-certain-page$ http://new-domain.com/another-certain-page [R=301,L]
#Redirect everything else to homepage
RewriteRule ^(.*)$ http://new-domain.com/ [R=301,L]
</IfModule>
让我知道这对您有何作用。如果您需要清除缓存,请尝试使用这些新规则。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句