1

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?

5
  • First thing you might want to get rid of is (.*)+. Just make that .+ if you want to require at least one character. Commented Dec 9, 2012 at 14:14
  • A path, for RewriteRule, in a directory context (.htaccess or <Directory>), never start with a slash.
    – julp
    Commented Dec 9, 2012 at 15:10
  • yes thanks, although still doesn't solve the problem
    – Randomize
    Commented Dec 9, 2012 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
    Commented Dec 9, 2012 at 15:37
  • Your latest code should work "as is" so there is some other issue that is causing problem for you.
    – anubhava
    Commented Dec 10, 2012 at 10:32

1 Answer 1

0

Well I have found a solution:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.