Forum Moderators: phranque
From the Apache 2.2 docs I tried putting the following in my virthost container
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.[^.]+\.mysite\.com
RewriteRule ^(.+) %{HTTP_HOST}$1 [C]
RewriteRule ^www\.([^.]+)\.mysite\.com(.*)www.mysite.com/$1$2
I set RewriteLogLevel 9 and can see that comparisons are indeed being made for every VALID page request, but 404s never seem to be compared at all. And you know in my naieve frustration I can't help but think they wouldn't even BE 404s if they were compared and rewritten first! And while I do think that last sentence may be the key, I still can't see it. Can someone point me toward the highway? Thanks in advance.
FWIW my webmaster skills rely heavily on the ctrl-C and ctrl-V keyboard combinations
:)
(I'm only half-kidding)
RewriteEngine on
#
# Redirect to canonicalize www.username.example.com to username.example.com
RewriteCond %{HTTP_HOST} ^www\.([^.]+)\.example\.com
RewriteRule ^/(.*)$ http://%1.example.com/$1 [R=301,L]
#
# Rewrite useername.example.com/<filename> to /user_dirs/useranme/<filename>
RewriteCond $1 !^user_dirs/
RewriteCond %{HTTP_HOST} !^www\.example.com
RewriteCond %{HTTP_HOST} ^([a-z][a-z0-9\-]*[a-z0-9])\.example\.com
RewriteRule ^/(.*)$ www.mysite.com/user_dirs/%1/$1 [L]
To avoid additional problems, you should require that all customers use subdomain names containing an all-lowercase alphabetic character to start, lowercase alphabetic, numeric or hyphen characters in the middle, and a lowercase alphabetic or numeric character to end. This is to comply with the HTTP URL-naming conventions, and to prevent access problems using the code above.
Jim
I accidentally gave some wrong information. When I type in http://smith.mysite.com I get an immediate DNS error, not a 404. So I apologize for that. And of course that's why there's no comparison in the Rewrite log!
I get that in both IE6 and IE7, so I'm going to go investigate the workings of these mysterious DNS records. hanks again for your help.
[1][[b]edited by[/b]: Dogvan at 9:01 pm (utc) on Dec. 18, 2007][/1]
I can't help but think that every site would want to see all traffic ending in their own domain name, that hosts would steer you toward a wildcard record by default. We're on a Verio VPS3 and that company, at least, does not breathe a word of it in the dummy self-help pages.
Wildcard DNS creates an opportunity for 'infinite duplicate-content' problems. Once you define wild-card DNS, it is up to you to be sure that each page on your site can be reached using one URL and one URL only. All the rest must return a permanent redirect, a 404-Not Found, or a 410-Gone response. To neglect this is to hand an axe to your most aggressive competitors, and ask them not to hit you... ;)
Hosting companies provide servers, and cannot be expected to provide in-depth training to their customers on advanced server configuration, SEO, and SEM topics. With the current pressure on hosting fees, it's a wonder they provide as much info as they do.
Jim