Forum Moderators: phranque

Message Too Old, No Replies

How to do mod_rewrite for subdomain?

Mod_Rewrite Subdomain

         

Darren884

12:05 am on Jan 24, 2005 (gmt 0)

10+ Year Member



How would I make a mod rewrite subdomain like this
ANYSUBDOMAIN.mydomain.com/CHOSEFILE.HTML

jdMorgan

3:19 am on Jan 24, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Darren884,

Welcome to WebmasterWorld!

Making a rewrite for <some_subdomain>.example.com/anyfile to example.com/subdomain/anyfile is easy. Doing it for <any_subdomain>.example.com/anyfile is easy only if your server is running FreeBSD or some other Unix-type OS that supports POSIX 1003.2 regular-expressions, or if you place the code in httpd.conf, rather than trying to do this in your Web root .htaccess.

See this thread on how to rewrite arbitrary subdomains to subdirectories [webmasterworld.com] for more info on this method.

If your server does not support POSIX 1003.2 regex and you want to implement this in .htaccess, then you'll have to explicity define the valid subdomains and the subdirectories you map them to.

Jim

[edited by: jdMorgan at 7:29 pm (utc) on Jan. 24, 2005]

Darren884

6:23 pm on Jan 24, 2005 (gmt 0)

10+ Year Member



Hi it does support that and I already have wildcard subdomains turned on.

jdMorgan

7:30 pm on Jan 24, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Good, then the code posted in message #6 of the referenced thread will allow you to map any requested subdomain to the subdirectory of the same name. (I have fixed the link, which was apparently broken)

Jim