Welcome to WebmasterWorld Guest from 54.226.241.8

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

subdomains and redirection

subdomain .htaccess redirect

     

Auras_jc

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?

jdMorgan

7:36 pm on Aug 17, 2003 (gmt 0)

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



Auras_jc,

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]

Jim

 

Featured Threads

Hot Threads This Week

Hot Threads This Month