I am migrating a site to a new domain and I would like to do a 301 redirect via the .htaccess file to create a redirect rule. I have over a 1000 dynamic links generated via views so this isn't do able with a redirect module as easily. I just want to get an example modrewrite rule to put in my .htaccess file.

2 Answers 2


Also have a look at the Redirect module. Managing redirects in the database might have some advantages over putting them in a .htaccess file.


Here's what i put in my .htaccess file:

I wanted to redirect urls from: www.abc.com/buy/tennis/shoes/1232

TO: www.xyz.com/buy/tennis/shoes/1232

Line 100:

RewriteRule ^buy(/?.*) http://www.xyz.us/buy$1 [R=301,L]

Note: You have to put this rule above the other rewriterules. I put it below the rewriterule ^ index.php and broke the site. just an fyi as I'm not exactly sure why it broke. if someone else can shed some light on this it would be great.

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.