Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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}   !www.university.edu$ [NC]
RewriteRule ^/(.*)$        http://www.university.edu/engineering/$1 [R=301]
RewriteRule ^index\.php$ - [L]

My intention is that any request to this web server that does not contain the domain name www.university.edu 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

1 Answer 1

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

RewriteRule ^(.*)$ http://www.university.edu/engineering/$1 [R=301]
share|improve this answer

Your Answer

 
discard

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.