Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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'm trying to add a wildcard sub-domain system to my web server, but its still not working,

These are the steps I took:

I made a new file, vhost.conf, in the directory var/www/vhosts/

And I put:

ServerAlias * 

Then second of all, I made a new DNS wildcard on Plesk:


And then I edited my .htaccess file:

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(^.*)\
RewriteRule (.*)  user.php?user=%1

Normally my URL would be:

But now, I want it like this:

But the steps I took still don't work.

:)) What's happening here?

share|improve this question

migrated from Dec 31 '10 at 4:15

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

up vote 1 down vote accepted

The proper CNAME definition for wildcard domains should be as such:


So in plesk you could try to edit the record and add that dot after the wildcard.

Of course you have to wait a bit for DNS propagation to occur, don't forget that.

Your htaccess also looks a bit wrong, although it should work, referring twice to the beginning of the string is a bit strange, try this instead:

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(.+)\.example\.com$
RewriteRule .*  user.php?user=%1 [L]

For more 1and1/Plesk specific info try to read the following tutorial:

share|improve this answer
i try to go to, but it shows me the 1and1 page, can you try it please thanks – Solomon Saleh Dec 30 '10 at 20:49
It seems that the Apache Vhost is not setup correctly. I'm not sure you can actually do wildcard domains with the hosting you have. I've no experience with 1and1, but it's a possibility that they don't allow it. If you can provide more info feel free. – Seldaek Dec 30 '10 at 20:55
i have linux dedicated server, and i also have root access!! so i must be able to do this, i think :)) im so stupid sorry – Solomon Saleh Dec 30 '10 at 20:56
Then yeah you should be able to ;) Try to force plesk to reload the stuff using /usr/local/psa/admin/sbin/websrcmng --reconfigure-vhost and then /sbin/service httpd restart – Seldaek Dec 30 '10 at 20:58
can i give you access to my linux server, and see whats wrong, becuase im shit at ssh command!!! please :( – Solomon Saleh Dec 30 '10 at 21:02
RewriteEngine on    
RewriteCond %{HTTP_HOST} !^www\.example\.com 
RewriteRule ^(.*)$ [R=permanent,L]

Please refer this link

How to redirect all urls to a www. subdomain

share|improve this answer

But the steps I took still don't work

That's not very helpful—what didn't work?

Do the names resolve? Does the web server respond to local requests for the domain? (NB the local interface on the server hardware may not be configured to the same address as the public IP&.) You would need to use something like Telnet to connect to the IP before submitting the HTTP request manually from the new host. Is the web server not differentiating between domains as expected? Is the rewrite rule not firing? You mention Plesk—implying that this is a hosted service. Are you sure mod_rewrite is available? Have you set up named vhosts on the same server by the same mechanism? How do you know that simply adding a new file in var/www/vhosts/ is all that's required? Usually I'd expect to restart the web server for the changes to be activated.

share|improve this answer
thanks for answering, can you try this is where my domain is – Solomon Saleh Dec 31 '10 at 10:28
its not redirecting, and i dnt know where that webpage is coming from – Solomon Saleh Dec 31 '10 at 10:29

Apache already has excellent support for mass vhosting; I suggest you take a look at how to set that up.

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.