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

htaccess redirect and wildcard DNS
redirecting a user generated subdomain name to a specific page

10+ Year Member

Msg#: 3396484 posted 1:40 am on Jul 17, 2007 (gmt 0)


I'd appreciate any advice on this :)

We're using wildcard DNS on a site and I'm wanting to redirect like so:


to display the page:


The username in the above example, "fred", isn't something we'll have control over - the user will select that when they sign up.

Thanks in advance!



10+ Year Member

Msg#: 3396484 posted 1:47 am on Jul 17, 2007 (gmt 0)

Whoops, looks like I need to search a little better - found a stack of other posts that most likely have the answer I need. Please excuse the false alarm :).


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

Msg#: 3396484 posted 2:12 am on Jul 17, 2007 (gmt 0)

If you're writing a rewrite rule to 'map' username-subdomains to directories, then you *will* have to take control over those usernames. They will have to be:

valid HTTP subdomain strings,
valid HTTP URL-strings, and
valid *nix filepath strings.

I strongly suggest that you accept *only* username strings containing lowercase letters, numbers, and hyphens, and further, that the username must start with a letter and end with a letter or a number. That will keep you out of trouble with the various protocol and filesystem requirements.

You can code the mod_rewrite accordingly, but the new-user sign-up script must enforce the "rules" above, so as not to allow creation of accounts that cannot be accessed.


[edited by: jdMorgan at 2:19 am (utc) on July 17, 2007]

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