1

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?

ctype.h
  • 205
  • 1
  • 3
  • 11
Solomon Saleh
  • 193
  • 2
  • 9

4 Answers4

1

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

Seldaek
  • 126
  • 2
  • 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. –  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` –  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
  • thats the tutorial i was following, and it was wrong!! lool – Solomon Saleh Dec 30 '10 at 21:03
  • Well I am sorry but I think you should rather ask in the 1and1 forums for specific help, or contact 1and1 support directly. I can not in good conscience let you give me root access to your server. –  Dec 30 '10 at 21:21
0
RewriteEngine on    
RewriteCond %{HTTP_HOST} !^www\.example\.com 
RewriteRule ^(.*)$ http://solomon.example.com [R=permanent,L]

Please refer this link

https://stackoverflow.com/questions/4520140/how-to-redirect-all-urls-to-a-www-subdomain/4520174#4520174

0

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.

ctype.h
  • 205
  • 1
  • 3
  • 11
symcbean
  • 21,009
  • 1
  • 31
  • 52
0

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

adaptr
  • 16,576
  • 23
  • 34