Author |
|
nitesh.apte
Joined: 25 Aug 2010 Posts: 21 Location: India
|
Posted: Mon 15 Nov '10 14:06 Post subject: Virtual Subdomain |
|
|
Hi
I have project folder in /var/www named domain(i.e. /var/www/domain). I have created virtual host www.domain.com pointing to /var/www/domain. Is it possible that www.domain.com and www.subdomain.domain.com should point to /var/www/domain? Because, requirement is like when different user access the portal, they should see their logo and images. So, plan is like we create account and a URL like www.client.domain.com. When client/user will access this link, URL will be parsed and accordingly their logos will be displayed. And in actual, there is no subdomain folder is present.
So, is it possible that www.domain.com and www.subdomain.domain.com should point to /var/www/domain?
Thanks |
|
Back to top |
|
glsmith Moderator
Joined: 16 Oct 2007 Posts: 2268 Location: Sun Diego, USA
|
|
Back to top |
|
nitesh.apte
Joined: 25 Aug 2010 Posts: 21 Location: India
|
Posted: Tue 16 Nov '10 13:26 Post subject: |
|
|
I tried as per your description. Nothing happened. Here is the my VirtualHost setting:
<VirtualHost 127.0.1.1>
ServerName www.domain.com
ServerAlias *.domain.com
DocumentRoot /var/www/domain
UseCanonicalName Off
DirectoryIndex index.php
<Directory /var/www/domain>
AllowOverride All
Options All
</Directory>
</VirtualHost>
Entry in /etc/hosts:
127.0.1.1 www.domain.com
Am I doing something wrong?
Thing is like, I don't want manual entries like www.(anything).domain.com inside <VirtualHost>. But, I want that any subdomain (like www.(anything).domain.com) entered in URL should point to /var/www/domain. Is this possible? |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7371 Location: Germany, Next to Hamburg
|
Posted: Tue 16 Nov '10 14:36 Post subject: |
|
|
You also have to add the other test domains into your hosts file
e.g. /etc/hosts
Also the IP you entered is wrong.
right 127.0.0.1
wrong 127.0.1.1
Change that in the apache config file and in the hosts file
Your ServerAlias is correct with the wildcard[1]
[1] http://httpd.apache.org/docs/2.2/en/vhosts/name-based.html#using |
|
Back to top |
|
nitesh.apte
Joined: 25 Aug 2010 Posts: 21 Location: India
|
Posted: Tue 16 Nov '10 15:21 Post subject: |
|
|
That's the thing. I don't want to enter the subdomain URL in /etc/hosts. We are planning like in www.(anything).domain.com - (anything) will be our client name. There are more than 50 client (and will increase in future) and they want to see their company logos when they access a subdomain. From subdomain name we will parse URL and will query our database and will show their logos and images. So making entries /etc/hosts file for so many client is not a good idea. So, is there any way that we can achieve this (without entry in /etc/hosts)?
Or, may be we have to provide a simple login page. So that, after login they can see their logos and images.
Hope, I explained my problem properly. If there is a way to achieve the above said requirement, please help me out. |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7371 Location: Germany, Next to Hamburg
|
Posted: Tue 16 Nov '10 20:29 Post subject: |
|
|
If you don't want to put that into your host file (which works only localy) you have to use a DNS server which offers wildcard support. |
|
Back to top |
|
nitesh.apte
Joined: 25 Aug 2010 Posts: 21 Location: India
|
Posted: Wed 17 Nov '10 13:08 Post subject: |
|
|
Thanks a lot for idea. I made it work. I installed bind9 on my system and did the required configuration. Now, no need to enter anything in /etc/hosts.
There is only one problem, when I restart my system, entries made in /etc/resolv.conf file get deleted. How can I fix this? |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7371 Location: Germany, Next to Hamburg
|
Posted: Wed 17 Nov '10 14:30 Post subject: |
|
|
Which Distro do you use? I guess the resolve.conf is deleted cause you use DHCP and the system generates a new resolv.conf to put in the newest DNS server and stuff. |
|
Back to top |
|
nitesh.apte
Joined: 25 Aug 2010 Posts: 21 Location: India
|
Posted: Sat 20 Nov '10 16:08 Post subject: |
|
|
I am using Ubuntu 10.04. By the way, I solved the problem. I made an entry in dhcpclient.conf file - prepend domain name as my IP address.
By the way, thanks a lot for you guys' concern. |
|
Back to top |
|