Skip to content
Redfin Solutions logoRedfin Solutions logoContact
arrow carved into wall

Create a Redirect in Drupal's .htaccess For The Base URL

I recently needed to redirect a client's traffic from their old URL to a new one. In this case, they wanted any traffic going to plain to go to and all other traffic to go to[equivalent URI] (e.g., -->

To do this, I messed around with rewrite rules and conditions for a while, until I decided on what seems to be a fairly straight forward solution:

# Redirect to
RewriteCond %{HTTP_HOST} ^
RewriteRule ^$ [r=301,L]
# Redirect to
RewriteCond %{HTTP_HOST} ^
RewriteRule ^(.*)$$1 [r=301,L]

The key here is "RewriteRule ^$", which looks for an empty pattern for the request URI, that is, the portion of the URL AFTER http:// and the host name (e.g., That way, if a person just enters in "" it will redirect them to The second section of the code is there to redirect all other traffic to a similar page on (taking everything matched after and slapping it in after

Pretty simple and so far it's working well. In my case, I also added a similar bit of code to redirect "www." traffic as well per Drupal's default .htaccess directions.