How can I setup dynamic sub domains?
August 7, 2006 12:09 AM   Subscribe

Sub-sub domains with mod_rewrite - can it be done?

I'm setting up a bunch of domains that follow a consistent naming structure (category/subcategory/file.html). I've setup dynamic wildcards on these domains, and I know how to handle pathing dynamically via PHP, but I'm really interested in setting up a solution like this:

user enters http://subcategory.category.domain.com/index.html, which rewrites to domain.com/category/sucategory/index.html, without changing the browser path.

As an added level of complexity, i'd like to be able to use drupal on some of the subpaths, so I need to be able to honor their htaccess to rewrite their query string.

Any help would be much appreciated, oh tech gods of Mefi!
posted by Vantech to Technology (4 answers total) 2 users marked this as a favorite
 
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST}<>%{REQUEST_URI} ^([^.]+)\.vantech\.com(:80)?<>/([^/]*) [NC]
RewriteCond %1<>%3 !^(.*)<>\1$ [NC]
RewriteRule ^(.*) /%1/$1 [L] 
That ought to work, but replace vantech.com with your site as required.
posted by PuGZ at 1:05 AM on August 7, 2006


Response by poster: Great reply PuGZ.

I'm running into trouble with the above ruleset however. It's throwing a 500.

On sub.sub domains - it isn't working at all. If the folder exists, it throws the above mentioned server 500. Any ideas?
posted by Vantech at 1:26 AM on August 7, 2006


Response by poster: As expected... it's throwing a mod_rewrite: maximum number of internal redirects reached. to the error_log
posted by Vantech at 1:28 AM on August 7, 2006


D'oh, I posted that without properly reading your question. Give me a little while!
posted by PuGZ at 3:01 AM on August 7, 2006


« Older TV or not TV?   |   Share your share knowledge, please! Newer »
This thread is closed to new comments.