Adding a Parameter at End of all url matching a format through Htaccess

对着背影说爱祢 提交于 2019-12-12 22:55:48

问题


Pl advise

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**

For ex Incorrect URL

 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

Correct URL

 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

HTACCESS CODE TRYING

 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]

回答1:


Try this rule:

 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]


来源:https://stackoverflow.com/questions/21497326/adding-a-parameter-at-end-of-all-url-matching-a-format-through-htaccess

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!