Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

share|improve this question

1 Answer 1

up vote 3 down vote accepted

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]
share|improve this answer
    
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

 
discard

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.