0

I have a web site / app where each user as a profile i.e.:
mydomain.com/user1
mydomain.com/user2
mydomain.com/user3
etc

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:
user1theirdomain.com they see there profile at mydomain.com/user1, 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?

1
  • 2
    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 Commented Aug 7, 2010 at 12:41

3 Answers 3

0

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

0

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).

3
  • 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 Commented Aug 7, 2010 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. Commented Aug 7, 2010 at 15:26
  • Ah I see, better use HTTP_HOST, not SERVER_NAME. (but depends on the actual webserver) Commented Aug 7, 2010 at 15:29
-1

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

<html> <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="http://mydomain.com/userfoo" /> </frameset> </html> 

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

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.