Virtual subdomain redirect (.htaccess?)

Virtual subdomain redirect (.htaccess?)

Posted by: IanWatson
Posted on: 2009-04-20 11:53:00

I'm wondering if there's a way to set up a system such that any attempts to reach the (non-existent) subdomain username.website.com would instead be redirected to (for example) www.website.com/code.php?id=username.

I do have one or two actual subdomains up already, which I hope would not be affected by this setup.

I suspect this would involve editing .htaccess, but my familiarity with the vagaries of .htaccess is rather limited.

Any help would be appreciated. Thanks in advance.

Re: Virtual subdomain redirect (.htaccess?)

Posted by: Atropos7
Posted on: 2009-04-20 13:07:00

In reply to:

I'm wondering if there's a way to set up a system such that any attempts to reach the (non-existent) subdomain username.website.com would instead be redirected to (for example) www.website.com/code.php?id=username.


First you need a wildcard DNS entry and a virtual host with a wildcard ServerAlias.

In reply to:

I do have one or two actual subdomains up already, which I hope would not be affected by this setup.


In the server configuration, the virutal host with the wildcard ServerAlias directive would have to appear after the virutal hosts for the two subdomains.

In reply to:

I suspect this would involve editing .htaccess, but my familiarity with the vagaries of .htaccess is rather limited.


It's an advanced setup that DreamHost doesn't offer. They would have to set it up manually and I doubt they would do so for inexperienced customers or those that can't demonstrate a real need for this functionality.

Edit: See this article in the Wiki - http://wiki.dreamhost.com/Wildcard_DNS

cool openvein.org -//- Edited by Atropos7 on 04/20/09 01:13 PM (server time).

Re: Virtual subdomain redirect (.htaccess?)

Posted by: IanWatson
Posted on: 2009-04-20 13:09:00

D'oh!

Thanks for the information. I'll have to try to find some other way around the issue.

Tags: subdomainsthanks in advanceattempts