redirecting url with parameters to same url without parameters

无人久伴 提交于 2020-01-14 02:58:07

问题


Using the file .htaccess, I am trying to redirect urls like this:

http://www.mysite.com/a-page/?fp=123&sp=456&tp=789

to:

http://www.mysite.com/a-page/

so basically redirecting url not caring about params values to the same url without any param.

I have used RewriteCond/RewriteRule, Redirect and RedirectMatch but without any luck.

My latest try was:

 RewriteCond %{QUERY_STRING} ^.+$
 RewriteRule ^a-page/$ http://www.mysite.com/a-page/? [L,R=301]

Any suggestion?


回答1:


Well I have found a solution:

RewriteCond %{QUERY_STRING} . [NC]
RewriteCond %{REQUEST_URI} /a-page/
RewriteRule ^ a-page/? [L,R=301]


来源:https://stackoverflow.com/questions/13788128/redirecting-url-with-parameters-to-same-url-without-parameters

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