繁体   English   中英

.htaccess mod_rewrite在Wordpress中的顺序

[英].htaccess mod_rewrite order in Wordpress

我正在尝试将旧网页流量重定向到另一个网页,同时保持某些链接正常运行,并使用Wordpress中的.htaccess RewriteRule指向新站点上的相同内容。

我使用漂亮的永久链接,而当我尝试重定向其余无法解决的内容时,它们的重定向很好。

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^blog$ http://newsite.com/news/ [R=301,L]
RewriteRule ^news/(.*)$ http://newsite.com/news/$1/ [R=301,L]
RewriteRule ^old-category/(.*)$ http://newsite.com/news/$1/ [R=301,L]
</IfModule>

上面的方法工作正常,即使有人使用类似

http://www.myoldsite/?p=1045       

一旦我添加类似

RewriteRule ^(.*)$ http://www.newsite.com [R=301,L]

它产生这样的链接

htttp://mynewsite/?p=1045

我无法确定这些规则的处理顺序。 我想让漂亮的永久链接生成,然后如果不遵循上述任何规则,请转到newsite.com下的主页。 我该怎么做呢?

尝试这个

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} p=1045$
RewriteRule ^(.*) http://newsite.com/tutorials? [R=301,L] 
RewriteRule ^blog$ http://newsite.com/news/ [R=301,L]
RewriteRule ^news/(.*)$ http://newsite.com/news/$1/ [R=301,L]
RewriteRule ^old-category/(.*)$ http://newsite.com/news/$1/ [R=301,L]
RewriteRule ^(.*)$ http://www.newsite.com/? [R=301,L]
</IfModule>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM