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'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/www.example.com/conf/vhost.conf.

And I put:

ServerAlias *.domain.com 

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

CNAME *domain.com example.com

And then I edited my .htaccess file:

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

Normally my URL would be:

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

But now, I want it like this:

http://solomon.example.com

But the steps I took still don't work.

:)) What's happening here?

share|improve this question

migrated from stackoverflow.com Dec 31 '10 at 4:15

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

4 Answers 4

up vote 1 down vote accepted

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

*.example.com CNAME example.com.

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: http://www.1and1faq.com/forums/archive/index.php/t-602.html

share|improve this answer
    
i try to go to solomon.kornar.com, 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 --vhost-name=example.com 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 ^(.*)$ http://solomon.example.com [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/www.kornar.com/conf/vhost.conf 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 solomon.kornar.com 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

 
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.