Good Evening….
i have my site in wordpress and i don’t want query string url to index in google search result, so for this i used below code for home page url like this
RewriteCond %{QUERY_STRING} .
RewriteRule ^$ /? [R=301,L]
RewriteCond %{THE_REQUEST} ?
RewriteCond %{QUERY_STRING} =""
RewriteRule .? %{REQUEST_URI}? [R=301,L]
by using the above code below url automatically redirect to home url…
http://example.com/? or http://example.com/?paramater=1
redirect on…
but my concern is that the above code is not working for sub folder or sub directories like..
http://example.com/folder/?paramater=1 or http://example.com/folder/?
should be redirect on..
http://example.com/folder/ or http://example.com/folder/ respectively…..
can anybody help me in order to correct above code..
thanks
You can use the following code to remove query strings from urls :
The reason why your redirect is not working is because you are checking for empty query strings.
You need to check if the query string exists