Remove parameter from URL viac .htaccess

旧巷老猫 提交于 2019-12-20 04:51:58

问题


I need advice how to remove a parameter from the url using. Htcaccess

The condition is as follows:

redirect url from:

http://example.com/?movie=2&ref=nf

to:

http://example.com/?movie=2

I tried several options but I have not come to nothing

Thank you for your ideas / advice.

THX.


回答1:


Try adding the following to the .htaccess file in the root directory of your site.

RewriteEngine on
RewriteBase / 

#If request contains ref param
RewriteCond %{THE_REQUEST} \?([^&\ ]+)&ref=  [NC]  
#redirect to URL without the ref param
RewriteRule ^  %{REQUEST_URI}?%1 [L,R=301] 


来源:https://stackoverflow.com/questions/9301125/remove-parameter-from-url-viac-htaccess

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