Subdomain to directories - Please HELP!!!

Using a single web hosting account to host multiple sites

Subdomain to directories - Please HELP!!!

Postby alexandru.nedelcu » Fri Nov 21, 2008 11:56 am

I'm a begginer in mod_rewrite. I understood what does it do and now I want to know what I have to do for my local website (localhost) to work.

How to obtain from
http://[subdomain].localhost
this one ->
/srv/www/htdocs/subdomains/
?
Where must be put this string? In .htaccess file? What other changes is required? Is a clear installation of Apache.

Thanks![/quote]
alexandru.nedelcu
 
Posts: 2
Joined: Fri Nov 21, 2008 11:49 am

Postby richardk » Fri Nov 21, 2008 12:46 pm

Do you want all sub domains to go to /srv/www/htdocs/subdomains/ or do you want abc.localhost to go to /srv/www/htdocs/subdomains/abc?
Do you have access to the httpd.conf file?
What happens when you go to abc.localhost at the moment?
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby alexandru.nedelcu » Fri Nov 21, 2008 11:16 pm

I when I access the subdomain
abc.localhost
I want to go to
/srv/www/htdocs/subdomains/abc

I have access to httpd.conf.
When I access abc.localhost host is unreachable.
Should I edit httpd.conf? or it can be set only in .htaccess file?
alexandru.nedelcu
 
Posts: 2
Joined: Fri Nov 21, 2008 11:49 am

Postby richardk » Sun Nov 23, 2008 9:17 am

mod_vhost_alias was written for this task.

Uncomment (remove the #) from the following line in your http.conf file
Code: Select all
LoadModule vhost_alias_module modules/mod_vhost_alias.so

and (if this line exists (Apache 1.3 only))
Code: Select all
AddModule mod_vhost_alias.c


Then add the following to the end of your httpd.conf file
Code: Select all
NameVirtualHost         *:80

VirtualHost *:80>
    ServerName          localhost
    DocumentRoot        /srv/www/htdocs/
</VirtualHost>

<VirtualHost *:80>
    ServerName          0.localhost
    ServerAlias         *.localhost
    DocumentRoot        /srv/www/htdocs/subdomains/
    VirtualDocumentRoot /srv/www/htdocs/subdomains/%-2+
</VirtualHost>


When I access abc.localhost host is unreachable.

You will need to add the sub domains to your hosts file, eg.
Code: Select all
127.0.0.1 localhost
127.0.0.1 abc.localhost
127.0.0.1 def.localhost
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 20 guests

cron