-1

http://mywebsite.com/index.php?user=john

I want to rewrite that in .htaccess like http://john.mywebsite.com

Can you help me.

srinivasan
  • 21
  • 5
  • You cannot rewrite a URI to a subdomain. A subdomain is a completely different thing, not simply part of a url. So it's a sub domain you need to go and add. It's not something that mod_rewrite can help you with. – i-CONICA Dec 05 '14 at 13:39
  • 1
    @i-CONICA - you can, you'd have to set up wildcard subdomains ( http://stackoverflow.com/questions/13566226/creating-wildcard-sub-domain-using-apache-virtualhost ), but there's nothing technical stopping you from doing something like `RewriteRule ^index.php?user=(\w+) http://$1.website.com` – CD001 Dec 05 '14 at 13:44
  • I stand corrected. :) – i-CONICA Dec 08 '14 at 09:27

1 Answers1

0

You may want to look at wildcard subdomains - it'll need DNS config changes, and mod_rewrite may not like it at all. You should be able to analyse the hostname passed to the webserver within index.php though, and use that instead of the user GET parameter.

I'd be hesitant to try a purely mod_rewrite solution though.

stwalkerster
  • 1,646
  • 1
  • 20
  • 30