apache - htaccess rule to remove parameters -


struggling come .htaccess rule remove parameters it. want

http://www.example.com/page/competition.html?utm_medium=email&utm_campaign=11&utm_source=11&utm_term=11.gif

to rewrite

http://www.example.com/page/competition.html

so, right /page/compeition.html rewritten. grateful assistance. in advance

in question, state want long uri rewritten shorter one. unfortunately, isn't clear. assuming wish remove query string using redirect, can use following:

rewritecond %{query_string} ^utm_medium=email&utm_campaign=([^&]+)&utm_source=([^&]+)&utm_term=([^&]+)$ rewriterule ^ %{request_uri}? [r=302,l] 

this generalised condition , rule check utm information in query string. if present, strip out query string.

if wish page/competition.html, change rule this:

rewriterule ^(page/competition\.html)$ /$1? [r=302,l] 

if wish remove query string forming part of request page/competition.html, can use instead of above:

rewritecond %{query_string} !^$ rewriterule ^(page/competition\.html)$ /$1? [r=302,l] 

this tells apache check if query string not empty and, if isn't, strip out altogether.

to make redirect permanent, change 302 301.


Comments

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -