1

i have this url

http://www.example.com/user.php?user=solomon

i want to convert this into

http://solomon.example.com

how can i do this!! thanks :))

p.s. im using plesk

3

I'm not familiar with Plesk's capabilities, but on a LAMP server, you need to use Apache's mod_rewrite module and have a wildcard DNS setup for *.example.com through your DNS provider (either your registrar or your hosting provider).

Your .htaccess for your virtual host will look like this:

  Options +FollowSymLinks
  RewriteEngine On
  RewriteBase /
  RewriteCond %{HTTP_HOST} !www.example.com$ [NC]
  RewriteCond %{HTTP_HOST} ^(www.)?([a-z0-9-]+).example.com [NC]
  RewriteRule (.*) user.php?user=%2 [NC,QSA]
  • thanks,i have root access, how can i set a wildcard DNS thanks :)) – Solomon Saleh Dec 30 '10 at 18:43
  • 1
    Setting up a wildcard DNS for example.com (*.example.com) has to be done by whomever controls your DNS records. i.e. in your WHOIS record for example.com, the nameserver records point to the DNS server(s) that control your DNS zone; this is likely the same place where you registered your domain (GoDaddy.com, networksolutions.com, etc.). – gravyface Dec 30 '10 at 18:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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