Internal handling of subdomains

Well, it's not really an issue. Using "$1" is wrong because the .htaccess file get parsed in the domain directory, not the subdomain one, so in RewriteRule the "^(.*)$" regular expression is "/subdir/..." instead of the original request "/...".

There is no "corruption by internal processing" like that poster said. "$1" doesn't work just because the subdomain resides in the directory of the domain, and .htaccess files are recursive. Apache tries to read any .htaccess file present in all the parent directories of any document root.

Using "%{REQUEST_URI}" to redirect a website is the only correct way, even if the backreference "$1" works most of the time.
 
Last edited:
Thank you for the clarification.

I was pretty confused about it, cause both no-www.org and mod_rewrite FAQ use "$1".
I'll pass the message :)
 
If you add the subdomain as a regular domain then you do not have those issues.
 
Back
Top