0

I just cloned a drupal 7 site to another domain name. Now i want to only redirect some of the URLS from the old site to the new site. Problem is that I have many (300+) dynamically generated URLs via views. Most likely I will have to do this via .htaccess modrewrites doing a 301 redirect. Basically I want to do is this:

Site #1:

abc.com/products/shoe

abc.com/products/shoe/blue

abc.com/products/shirt/neon

Site #2:

xyz.com/products/shoe

xyz.com/products/shoe/blue

xyz.com/products/shirt/neon

-- Where would I create this modrewrite in the .htaccess file? on the bottom or do I have to edit anything else? also would it affect anything else?

1 Answer 1

1

There are three ways to tackle this.

  1. You can make the mod_rewrite rules in you Apache configuration. The benefit of this is that you can keep your Drupal .htaccess stock, so you don't need to worry about losing changes when you update core. How/where this goes depends on you have Apache configured. On my servers, I use virtual hosts, so I add a <IfModule mod_rewrite.c> inside the <Directory> section.

  2. You can edit the stock .htaccess that comes with Drupal. You need to add them above the main rewrite that punts to index.php, which starts on line 112 in Drupal 7.x HEAD. When you do this, you need to make sure you back up and restore this file when you update core (or track in RCS and merge changes).

  3. You can use a combination of the Pathologic and Redirect modules. Pathologic will set up rules that rewrite URLs in your content when they get rendered out. Redirect can set up 301/302 redirects for inbound requests.

Of the three choices, I try to avoid #2. I manage a lot of sites, and I don't want to keep track of which have custom .htaccess files.

Between #3 and #1, I tend to prefer #3 because I can have someone else manage this process via the UI. However, if I have a lot of URLs with common patterns, or for simple domain redirections, I will use #1. Typically, I end up using a combination of #1 and #3.

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.