Re: mod_rewrite and wildcard DNS
Echilon wrote:Ity's always a buit hit and miss, but I can't figure out why it's not working this time.
Server logs are always the first place I look when debugging rewrite directives.
I haven't slept in a few days and can't help but think this is either not going to work or at least far from the best way to do it, but give it a try.
Code:
RewriteEngine On
# Verify subdomain is not www or images
RewriteCond %{HTTP_HOST} !^(www|images) [NC]
# Extract the subdomain AND sub directory
RewriteCond %{HTTP_HOST} ^([^.]+)\.yourdomain\.net/(.*)/[NC]
# Pass subdomain and subdirectory to get variable
RewriteRule ^$ /home/mydomain/index.php?cal=%1&act=%2 [L]
# Verify subdomain is not www or images
RewriteCond %{HTTP_HOST} !^(www|images) [NC]
# Extract the subdomain part
RewriteCond %{HTTP_HOST} ^([^.]+)\.yourdomain\.net[NC]
# Pass subdomain to get variable
RewriteRule ^$ /home/mydomain/index.php?cal=%1 [L]