Recursive .htaccess redirects

Recently I came across a request on Twitter for an effective means to update the .htaccess file to redirect all pages to a new domain without having to update for all subdirectories.  Here are a couple choices which can be easily placed in the root .htaccess file.

OPTION 1 (this does not need the RewriteEngine module)

Option 2 (this requires the use of the RewriteEngine module)

  • Options +FollowSymLinks
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^$ [OR]
    RewriteCond %{HTTP_HOST} ^$
    RewriteRule (.*)$$1 [R=301,L]
Be Sociable, Share!