Wildcard DNS and multiple rewrite rules

Using a single web hosting account to host multiple sites

Wildcard DNS and multiple rewrite rules

Postby Neeon » Fri May 08, 2009 12:21 am

Ok, heres the problem. I'm trying to create multiple "SEO-friendly links" rules, and at the same time use subdomains

like if the url is
it's really :

This is really no hocus pocus, but, if the url was this;
it's really :

(I know that i have to set up wildcard DNS on my domain)

So my question is, how can i use subdomains in my mod_rewite to point to the $_GET variable "site".
My technical english is a bit rusty, so i really dont know any other way to explain my problem.
Posts: 10
Joined: Sun Apr 29, 2007 6:25 am

Postby richardk » Fri May 08, 2009 5:26 am

You can add the site variable before processing the main rules. Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
RewriteCond %{HTTP_HOST} ^([^\.]+)\.example\.com$ [NC]
# Note there's no L flag.
RewriteRule ^.*$ $0?site=%1 [QSA]

RewriteRule ^abc$ /def [QSA,L]
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 8 guests