301 Redirect with Drupal 7 and Drupal 6 via .htaccess

Not as straight forward as we are used, but it's actually easy once you figure out that 301 redirect it's a rewrite rule in Drupal 7 that has a certain position in .htaccess. So if you need to redirect an old non-existing rule (that rules URL Alias) to a new URL with Drupal 7, open .htaccess and right after:

# If your site is running in a VirtualDocumentRoot at http://example.com/,
  # uncomment the following line:
  # RewriteBase /

and then you can add something like this:

#custom  301 redirects

RewriteRule ^OLD_URL_1 http://NEW_URL_1 [R=301,L]
RewriteRule ^OLD_URL_2 http://NEW_URL_2 [R=301,L]

If you want to use spaces in RewriteRule use \ as delimiter, for example:

http://site/url\ with\ spaces.png

for the URL as:

http://site/url with spaces.png


This is relevant for …

Apache, Drupal

Post a comment