I am using RewriteRule (.*)$ http://www.longerdomain.com/$1 [R=301,L] to redirect a shorter domain and all it's pages to a longer domain. It is working great, but now I am needing to add a condition or an additional rule that allows for http://short.com/donate to redirect to http://longerdomain.com/donation-form. I have tried this Redirect 301 /donate http://www.longerdomain.com/donation-form after the RewriteRule, but with no success. How would I achieve this? Cheers.

1 Answer 1


The simplest way of doing it, using mod_rewrite,

RewriteRule ^/donate$ http://longerdomain.com/donation-form [R=301,L]

and place it before your general

RewriteRule (.*)$ http://www.longerdomain.com/$1 [R=301,L]

rule, as that rule will redirect anything given to it.

  • Note that if this is in .htaccess (as indicated by the question tag) then you'll need to remove the slash prefix from the URL-path matched by the RewriteRule pattern. ie. should be ^donate$, not ^/donate$
    – MrWhite
    Jan 13, 2021 at 3:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .