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
www.example.com/about/news/latest-article
it's really :
http://www.example.com/index.php?node=about&mod=news&call=latest-article

This is really no hocus pocus, but, if the url was this;
http://othersite.example.com/about/news/latest-article
it's really :
http://example.com/index.php?site=othersite&node=about&mod=news&call=latest-article

(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.
Neeon
 
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 %{ENV:REDIRECT_STATUS} ^$
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]
richardk
 
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 18 guests

cron