I need some help with .htaccess redirect.


ALL of them need to be redirected to ...


... without taking care of any parameters - can you help me?

2 Answers 2


Very easy, this is something you can easily find and figure out yourself.

# Check if the url STARTS WITH (is what the ^ does) '/test-music'
RewriteCond %{REQUEST_URI} ^/test-music
# redirect it, 301 style, Last line (we go away, no need to do the rest of the htaccess)
RewriteRule ^(.*) /music/ [L,R=301]
  • Very nice - Thanks! :-) But for me, I had to add a '?' after the last '/' - then all parameters will be deleted ... RewriteRule ^(.*) /music/? [L,R=301]
    – Nico
    Jul 8, 2015 at 23:54
  • Thats weird, because that isnt the regex part. I don't put the varaibles back in the url (that would mean $1 would be put there). But hey, if it works!
    – Martijn
    Jul 9, 2015 at 7:09
  • Seem that adding a ? after the new URL in the RewriteRule line is what makes the parameters not append to the URL. I think there may be a flag included with apache 2.4 that can be used to also force the removal of parameters as well but I'm not sure of the name of it. Jul 9, 2015 at 17:57
RewriteRule ^test-music\.html$ /music/ [L,R=301]
  • +1, this might be easier. But is a bit more limited, you can't do a if file doesnt exist check if someone wants that. Pick whichever suits you better :)
    – Martijn
    Jul 9, 2015 at 13:01

Your Answer

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

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