Noob Here.. 我的 Ubuntu 机器上有以下文件夹结构
/var/www/
/folder1
/folder2
现在我想将我的 url xyz.com 重定向到 folder1 和 xyz.com/blog 到 folder2。我正在使用以下 Vhost 配置文件
对于 xyz.com 到文件夹 1
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName xyz.com
ServerAlias www.xyz.com
DocumentRoot /var/www/folder1
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
.......
</VirtualHost >
对于 xyz.com/blog 到 folder2
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName xyz.com/blog
ServerAlias www.xyz.com/blog
DocumentRoot /var/www/folder2
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
.......
</VirtualHost >
当我在 url 中输入 xyz.com 时,它为我提供来自 folder1 的索引文件(如预期和正确)但是当我输入 xyz.com/blog 它显示 404:未找到错误
Not Found
The requested URL /blog/ was not found on this server.
Apache/2.2.22 (Ubuntu) Server at socialcosmo.com Port 80
我已经花了几个小时在这上面,仍然无法找出问题:(
任何帮助将不胜感激
最佳答案
没有包含路径的主机(域名)之类的东西。 xyz.com/blog
不是有效的 ServerName
.
删除第二个虚拟主机并添加 alias directive给你的第一个。Alias /blog /var/www/folder2
关于apache - 错误为属于同一域的文件夹设置 VirtualHost,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15914501/