Wildcard subdomain -> subdir Rewrite help please

Using a single web hosting account to host multiple sites

Wildcard subdomain -> subdir Rewrite help please

Postby mvandemar » Thu Mar 22, 2007 9:19 pm

Ok, not sure why this is failing. I have the wildcard DNS set up so all subdomains point to the same folder. Now I am trying to map all non-www subdomains to subfolders. This works:
Code: Select all
RewriteCond %{HTTP_HOST} ^(.*)\.mydomain\.com$ [NC]
RewriteCond %1 !^www$ [NC]
RewriteRule ^$ /dablogs/%1/ [L]


However, when I try and map the paths further in, I start getting 500 errors, no matter what I try:

Code: Select all
RewriteCond %{HTTP_HOST} ^(.*)\.mydomain\.com$ [NC]
RewriteCond %1 !^www$ [NC]
RewriteRule (.*) /dablogs/%1/$1 [L]


and

Code: Select all
RewriteCond %{HTTP_HOST} ^(.*)\.mydomain\.com$ [NC]
RewriteCond %1 !^www$ [NC]
RewriteRule ^(.*)$ /dablogs/%1/$1 [L]


Both give 500 errors, whereas:

Code: Select all
RewriteCond %{HTTP_HOST} ^(.*)\.mydomain\.com$ [NC]
RewriteCond %1 !^www$ [NC]
RewriteRule ^/(.*)$ /dablogs/%1/$1 [L]


Doesn't give any errors, however, it doesn't remap anything at all either (just pulls from the root folder). By the way, it also works fine if I assume a fictional directory:

Code: Select all
RewriteCond %{HTTP_HOST} ^(.*)\.mydomain\.com$ [NC]
RewriteCond %1 !^www$ [NC]
RewriteRule ^tested/(.*)$ /dablogs/%1/$1 [L]


works fine. I just cannot get it to work correctly for root requests, which is what my goal is.

Any ideas? Thanks! :)

-Michael
mvandemar
 
Posts: 2
Joined: Thu Mar 22, 2007 9:16 pm

Update...

Postby mvandemar » Thu Mar 22, 2007 11:43 pm

Ok, the following code does not return a 500 error:

Code: Select all
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} ^(.*)\.mydomain\.com$ [NC]
RewriteCond %1 !^www$ [NC]
RewriteRule ^(.*)$ /dablogs/%1/$1 [L]


I am assuming that the problem was an infinite loop before, and the new first line is preventing that (if I am mistaken then please correct me). And it works insofar as when I go to sub1.mydomain.com, it correctly pulls up the index of:

/dablogs/sub1

In /sub1, I have a folder named /test, and it does display correctly. However, when I click on /test now, I get a 404. So, seems like progress, but still not there.

EDIT: NM, there was an erroneous .htaccess file on the loose, works now. :D

-Michael
mvandemar
 
Posts: 2
Joined: Thu Mar 22, 2007 9:16 pm


Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 31 guests

cron