简体   繁体   中英

Name-based virtual host isn't working

I'd like to know if name-based virtual hosting is the same as domain mapping as that is what I am trying to achieve.

I am trying to host multiple folders/websites on the same server/ip address

This is what my virtual host/apache2.conf looks like I have restarted apache2 and no dice, always going to the root or var/www folder showing a directory/index list

NameVirtualHost *:80

<VirtualHost *:80>
ServerName www.site1.us
ServerAlias site1.us
DocumentRoot /var/www/site1
</VirtualHost>

<VirtualHost *:80>
ServerName www.site2.com
ServerAlias site2.com
DocumentRoot /var/www/site2
</VirtualHost>

Perhaps I can do it by .htaccess instead, I would like to have my websites point to their individual domains.

The other problem is that the links within each folder/site point back to the primary ip/location eg. /var/www so that's messed up as well.

I was following the manual here and I don't know what I am missing

http://httpd.apache.org/docs/2.2/vhosts/name-based.html

If you're getting a directory listing, you might not have access/permissions for where you put the files. I had that problem until I set up a symlink and added a Directory directive to my host definition. It looked like this:

<Directory "/">
        Require all granted
        Options FollowSymLinks
        AllowOverride None
</Directory>

Hopefully that helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM