.htaccess 301将旧动态页面重定向到静态页面

时间:2016-06-13 03:47:45

标签: .htaccess redirect mod-rewrite url-rewriting

我查看了其他一些问题,但似乎没有解决方案可行。这是我必须做的一些13k 301重定向的快速示例。以下是其中之一:

www.mysite.com/beta/index.php/cataloga/category/index.php?option=com_content&view=article&id=55&Itemid=3
to
www.mysite.com/applications/

所以这就是我尝试过的:

Options +SymLinksIfOwnerMatch -Indexes
RewriteEngine On
RewriteBase /

RewriteCond %{QUERY_STRING} ^option=com_content&view=article&id=55&Itemid=3
RewriteRule ^/beta/index.php/cataloga/category/index.php$ /applications/ [R=301,L]
RewriteRule /applications/ ^Itemid=3  [R=301,L]
RewriteRule ^Itemid=3 /applications/ [R=301,L]
RedirectMatch 301 ^/id=55&Itemid=3/.*$ /applications/
Redirect 301 /beta/index.php?option=com_content&view=article&id=55&Itemid=3 /applications/

修改 以下是我需要转到/compare/的另一个示例网址:

/beta/index.php/index.php/products/mysite/index.php/cataloga/category/index.php?option=com_content&view=article&id=37&Itemid=16

要检查重定向是否正常工作,我测试了它并且它工作正常:

Redirect 301 /beta/index.php/products/hyperpress /

1 个答案:

答案 0 :(得分:1)

尝试此规则:

Options +SymLinksIfOwnerMatch -Indexes
RewriteEngine On

RewriteCond %{QUERY_STRING} ^option=com_content&view=article&id=55&Itemid=3\b
RewriteRule (^|/)index\.php$ /applications/? [R=301,L,NC]

RewriteCond %{QUERY_STRING} ^option=com_content&view=article&id=37&Itemid=16\b
RewriteRule (^|/)index\.php$ /compare/? [R=301,L,NC]
  • htaccess中没有匹配前导斜杠
  • 目标URI末尾的
  • ?将剥离查询字符串