Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to write a ReriteRule in an .htaccess file that will redirect requests to our new domain. This is the rule I'm trying to use.

RewriteEngine On
RewriteBase /
# Domain name fix
RewriteCond %{HTTP_HOST}   !$ [NC]
RewriteRule ^/(.*)$$1 [R=301]
RewriteRule ^index\.php$ - [L]

My intention is that any request to this web server that does not contain the domain name will be redirected to the engineering subsite. Everything hosted on this web server must appear as coming from that subsite. This RewriteRule is not working. Am I using the wrong approach? Should I use a Vistual Host or a Server Alias instead?

share|improve this question

Since you're in an .htaccess file, there's no leading / on the path the RewriteRule matches. Change your RewriteRule to:

RewriteRule ^(.*)$$1 [R=301]
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.