2

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
</VirtualHost>

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.

Examples:

http://wackystore -> no change

http://wackystore/something -> no change

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

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

http://wackyprojects/something -> no change
Greg_the_Ant
  • 489
  • 7
  • 26

2 Answers2

2

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."

loopforever
  • 1,185
  • 8
  • 11
1

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
quanta
  • 51,413
  • 19
  • 159
  • 217