Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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?

share|improve this question
First thing you might want to get rid of is (.*)+. Just make that .+ if you want to require at least one character. – m.buettner Dec 9 '12 at 14:14
yes thanks, re-edited – Randomize Dec 9 '12 at 14:17
A path, for RewriteRule, in a directory context (.htaccess or <Directory>), never start with a slash. – julp Dec 9 '12 at 15:10
yes thanks, although still doesn't solve the problem – Randomize Dec 9 '12 at 15:13
Are you sure url rewriting is enabled? (implies at least AllowOverride FileInfo + RewriteEngine on) Do you have any other rule in this .htaccess? PS: Redirect* cannot work, they won't handle the query string. – julp Dec 9 '12 at 15:37
show 1 more comment

1 Answer

up vote 0 down vote accepted

Well I have found a solution:

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.