Drupal redirect in .htaccess

Using .htaccess is one of the best ways to redirect a URL to a new URL. Particular care needs to be taken with Drupal sites for it to work correctly.

The following snippets needs to be added to the root .htaccess file directly after the following lines:

# Various rewrite rules.
<IfModule mod_rewrite.c>
  RewriteEngine on
  .......
  # If your site is running in a VirtualDocumentRoot at <a href="http://example.com/,<br />
" title="http://example.com/,<br />
">http://example.com/,<br />
</a>  # uncomment the following line:
  # RewriteBase /

#custom redirectsRewriteRule ^oldpath$ <a href="http://www.example.com/newpath" title="http://www.example.com/newpath">http://www.example.com/newpath</a> [R=301,L]
#end custom redirects

More info on Ping Vision

Post new comment

The content of this field is kept private and will not be shown publicly.

Learn how to become a Drupal developer

Does Drupal development make your head explode and drive you crazy?

Why not learn from someone who has paved the way instead?

Sign up to my upcoming learning series.

Syndicate

Syndicate content

Hello!!

I am Blair Wadman and this is where I write about Drupal, PHP, CSS etc

Stuff

© Blair Wadman
2005 - 2011