homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

subdomains and redirection
subdomain .htaccess redirect

10+ Year Member

Msg#: 339 posted 11:22 am on Aug 17, 2003 (gmt 0)

I work at a firm that offers webhosting, and I want to host my site there. I don't work near the server so I won't get to configure it because it's somebody else's job. I will tell the administrator to create a virtual host for :
ServerName www.domain.com
ServerAlias *.domain.com

And I will not go to tell him to add me a new virtual host for every subdomain I want, so that's why I need a way to redirect using any means possible :D.
I've created a script using javascript and php to redirect every <subdomain>.domain.com to www.domain.com/<subdomain> but this doesn't work if i get <subdomain>.domain.com/image.jpg .
Is there a way using .htaccess file to get all the <subdomain>.domain.com/<file> from www.domain.com/<subdomain>/<file> and for the URL from the browser not having to change?



WebmasterWorld Senior Member jdmorgan us a WebmasterWorld Top Contributor of All Time 10+ Year Member

Msg#: 339 posted 7:36 pm on Aug 17, 2003 (gmt 0)


Welcome to WebmasterWorld [webmasterworld.com]!

Maybe something like this in .htaccess:

Options +FollowSymLinks
RewriteEngine on
RewriteCond {HTTP_HOST} !^www\.
RewriteCond {HTTP_HOST} ^([^\.]+)\.yourdomain\.com
RewriteRule ^(.*)$ /%1/$1 [L]

Ref: Introduction to mod_rewrite [webmasterworld.com]


Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved