Welcome to WebmasterWorld Guest from

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

htaccess redirect and wildcard DNS

redirecting a user generated subdomain name to a specific page

1:40 am on Jul 17, 2007 (gmt 0)

Junior Member

10+ Year Member

joined:Mar 9, 2002
votes: 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!

1:47 am on July 17, 2007 (gmt 0)

Junior Member

10+ Year Member

joined:Mar 9, 2002
votes: 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 :).
2:12 am on July 17, 2007 (gmt 0)

Senior Member

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

joined:Mar 31, 2002
votes: 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]