通过Htaccess在与格式匹配的所有URL的末尾添加参数 [英] Adding a Parameter at End of all url matching a format through Htaccess
本文介绍了通过Htaccess在与格式匹配的所有URL的末尾添加参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请告知
请告知,如何通过301重定向在所有网址匹配的末尾添加Itemid = 13
Pl advise, how to add Itemid=13 on end of all url matching by making 301 redirect
index.php?option=com_usedtoy&view=post&id=**variable**
对于前 网址错误
www.abc.com/index.php?option=com_usedtoy&view=post&id=495
www.abc.com/index.php?option=com_usedtoy&view=post&id=497
www.abc.com/index.php?option=com_usedtoy&view=post&id=510
正确的网址
www.abc.com/index.php?option=com_usedtoy&view=post&id=495&Itemid=13
www.abc.com/index.php?option=com_usedtoy&view=post&id=497&Itemid=13
www.abc.com/index.php?option=com_usedtoy&view=post&id=510&Itemid=13
成功代码尝试
RewriteEngine On
RewriteCond %{QUERY_STRING} (^|&)option=com_usedtoy(&|$) [NC]
RewriteCond %{QUERY_STRING} !(^|&)Itemid=13(&|$) [NC]
RewriteRule ^index\.php$ %{REQUEST_URI}/%{QUERY_STRING} [L,NC]
RewriteRule ^(index\.php)/(option=com_usedtoy&view=post)&(^id=.*)&((?!Itemid=13&).+)$ /$1?$2&Itemid=13&$3 [L,NC,R=301]
推荐答案
尝试以下规则:
RewriteEngine On
RewriteCond %{QUERY_STRING} (^|&)option=com_usedtoy(&|$) [NC]
RewriteCond %{QUERY_STRING} !(^|&)Itemid=13(&|$) [NC]
RewriteRule ^index\.php$ %{REQUEST_URI}?%{QUERY_STRING}&Itemid=13 [L,NC,R=301]
这篇关于通过Htaccess在与格式匹配的所有URL的末尾添加参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文