Recursive .htaccess redirects

jeremyschell

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} ^oldwebsiteaddress.com$ [OR]
    RewriteCond %{HTTP_HOST} ^www.oldwebsiteaddress.com$
    RewriteRule (.*)$ http://www.YourNewDomainAddressHere.com/$1 [R=301,L]

Recommended Posts

Bourbon Bourbon Hunting

Do you trust me? Just take my word for it, this is good …

Is there a meal or specific food that you remember as if you had it yesterday, no matter how long ago? Have these experiences shaped your personal palate and influenced the food and drink you consume to this day? Surprisingly, after nearly fifty years, I almost understand how my neanderthal brain functions, and with that, […]