Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a web site / app where each user as a profile i.e.:

How do I allow it so that a user can use their own domain name to go to their profile as a rewrite not a redirect. So when they go to lets say: they see there profile at, but I don't want a redirect, I want it so their domain is seen in the address bar.

I imagine the user will need to adjust there domain name DNS to point to my server, what are the correct procedures and what would I need to do from there?

Also I wouldn't want to manually adjust things, I'd like it so when they point their domain to my server, my app will check the domain name, lookup the domain in my database and then serve the correct content.

Any ideas?

share|improve this question

migrated from Aug 7 '10 at 16:21

This question came from our site for professional and enthusiast programmers.

that's entirely a serverfault question. both DNS ans web-server settings covered there. While you don't actually need a rewrite. there is nothing to rewrite as user already requesting your server – Col. Shrapnel Aug 7 '10 at 12:41
up vote 0 down vote accepted

why not just use virtual hosts? As long as DNS is setup correctly so that, or more specifically,, lands on your server, you can point the request to anywhere you need on the filesystem.

share|improve this answer

On the PHP side of things you'd just need a $user = user_domain($_SERVER["HTTP_HOST"]) mapping. However, your webserver needs to accept random vhosts if your users are just to 'point' to your server. So if you are on shared hosting, there's no way to set this up.

Why aren't user subdomains sufficient? That would just need a RewriteCond %{HTTP_HOST} (.+) and RewriteRule .+ user.php?domain=$1. And it's likewise easier to set this up for your users (as redirect though).

share|improve this answer
SERVER_NAME will never help and subdomains do not need any rewrite. and user supplied domain is widely used, as a personal blog using some blog-hosting for example – Col. Shrapnel Aug 7 '10 at 15:22
@CS: Most hosters allow to designate a catch-all target dir. Any %{SERVER_NAME} can easily be evaluated in .htaccess and PHPs $_SERVER. Subdomains don't necessitate separate subdirectories. – mario Aug 7 '10 at 15:26
Ah I see, better use HTTP_HOST, not SERVER_NAME. (but depends on the actual webserver) – mario Aug 7 '10 at 15:29

The easiest way to do this is with a 0-pixel frame. Basically, setup an IP address that people point their domain to, like On, have a frameset like this:

<frameset rows="0,100%">
  <frame noresize frameborder=0 marginheight=1 scrolling=no src="/blank_page.html" />
  <frame noresize frameborder=0 marginheight=1 scrolling=no src="" />

This could make some of your javascript more tricky...

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.