2016-06-13 145 views
1

我翻看了一些其他问题,但没有解决方案似乎工作。这里有一个我必须做的13k 301重定向的简单例子。这里是其中的一个:.htaccess 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

试试这个规则:

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] 
  • 斜线不是在目标URI结束htaccess的
  • ?匹配将剥离查询字符串
+0

谢谢,这样的工作。如果url有'id = 37&Itemid = 16',我想让它去一个不同的静态页面,虽然...即。 '/比较/' – ToddN

+0

好的,在这种情况下,你需要不同的规则,如我最近的更新中所示,以回答 – anubhava

+0

谢谢,适用于某些情况。请看我的编辑与长URL。为什么它不工作,当我只是尝试^ index.php $ – ToddN