Thursday, September 10, 2009

rewrite rules apache

How does one setup a server to read a directory domain on the fly?


#REDIRECT DOMAIN NAME TO pull from directory /web/DOMAINNAME.COM
RewriteCond %{HTTP_HOST} ^www\.(([a-z0-9_]+\.)?(.*))$ [NC]
RewriteRule .? /web/%1%{REQUEST_URI} [L]

#REDIRECT ANY NON-WWW to WWW
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .? http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

this code will allow you to on the fly create directories for domains and not have to bounce or change apache configuration.

1 comment:

  1. Wow that was unusual. I just wrote aan incredibly long comment but
    after I clicked subit my comment didn't appear. Grrrr...
    well I'm not writing all that over again.
    Anyways, just wanted to say excellent blog!

    Here is myy page ... popular muskurahat tcvdetails hd videos music

    ReplyDelete

Got a Suggestion please let us know