Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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 have Apache 2.0 set up with a virtual host like this:

<VirtualHost *:80>
     ServerName wackystore
     ServerAlias wackyprojects
     Alias /media/admin /opt/python/lib/python2.7/site-packages/django/contrib/$
     Alias /media /opt/DjangoProjects/wacky/media
     #mod_wsgi setup
     WSGIScriptAlias / /opt/DjangoProjects/wacky/django.wsgi

I have our DNS set up so both "wackystore" and "wackyprojects" go to this server.

What I want to have happen is for mod rewrite to change the url for wackyprojects to wackprojects/tools.


http://wackystore -> no change

http://wackystore/something -> no change

http://wackyprojects/ -> http://wackyprojects/tools

http://wackyprojects -> http://wackyprojects/tools

http://wackyprojects/something -> no change
share|improve this question
up vote 1 down vote accepted

Something like this should work:

RewriteCond %{HTTP_HOST} ^wackyprojects$ [NC]
RewriteCond %{REQUEST_URI} ^/*$
RewriteRule .* http://wackyprojects/tools [R,L]

"If the HTTP_HOST is wackyprojects and the REQUEST_URI is / or nothing at all, then rewrite the request to http://wackyprojects/tools and stop there."

share|improve this answer
Wow that's so simple! Now why couldn't I figure that out from the docs :-( Thanks a bunch! – Greg_the_Ant Aug 12 '11 at 15:19
What are the [NC] and [R,L] for? – Greg_the_Ant Aug 12 '11 at 15:20
NC = no case (case insensitive), R = redirect, L = last (no more rules processed). See more here: – loopforever Aug 12 '11 at 15:21

Try this:

RewriteEngine   on
RewriteCond %{HTTP_HOST}    wackyprojects [NC]
RewriteRule ^/$             http://wackyprojects/tools [L,R]
  • NC flag means no case
  • L - Last rule and R - force redirect
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.