在询问此问题之前,我检查了here,here,here,here和here。我想我的搜索能力很弱。
我使用的是WampServer版本2.2e
。我有需要,我需要一个虚拟主机内的虚拟路径。让我说一下我拥有的两位主持人。
NameVirtualHost *:80
<VirtualHost *:80>
ServerName localhost
DocumentRoot "C:/Wamp/www"
</VirtualHost>
<VirtualHost *:80>
ServerName apps.ptrl
DocumentRoot "C:/Wamp/vhosts/ptrl/apps"
ErrorLog "logs/apps-ptrl-error.log"
CustomLog "logs/apps-ptrl-access.log" common
<Directory "C:/Wamp/vhosts/ptrl/apps">
allow from all
order allow,deny
AllowOverride All
</Directory>
DirectoryIndex index.html index.htm index.php
</VirtualHost>
<VirtualHost *:80>
ServerName blog.praveen-kumar.ptrl
DocumentRoot "C:/Wamp/vhosts/ptrl/praveen-kumar/blog"
ErrorLog "logs/praveen-kumar-ptrl-error.log"
CustomLog "logs/praveen-kumar-ptrl-access.log" common
<Directory "C:/Wamp/vhosts/ptrl/praveen-kumar/blog">
allow from all
order allow,deny
AllowOverride All
</Directory>
DirectoryIndex index.html index.htm index.php
</VirtualHost>
我现在的要求是http://apps.ptrl/blog/
和http://blog.praveen-kumar.ptrl/
应该是同一个目录。我想到的一件事是,移动blog
文件夹中的apps
文件夹,但它与Git
连接,其他东西都存在,因此无法移动文件夹。
所以,我想以这种方式为alias
创建VirtualHost
:
<VirtualHost *:80>
ServerName apps.ptrl
DocumentRoot "C:/Wamp/vhosts/ptrl/apps"
ErrorLog "logs/apps-ptrl-error.log"
CustomLog "logs/apps-ptrl-access.log" common
<Directory "C:/Wamp/vhosts/ptrl/apps">
allow from all
order allow,deny
AllowOverride All
</Directory>
DirectoryIndex index.html index.htm index.php
# The alias to the blog!
Alias /blog "C:/Wamp/vhosts/ptrl/praveen-kumar/blog"
<Directory "C:/Wamp/vhosts/ptrl/praveen-kumar/blog">
allow from all
order allow,deny
AllowOverride All
</Directory>
</VirtualHost>
但是当我尝试访问http://apps.ptrl/blog
时,我收到了Error 403 Forbidden
页。
我做对了吗?如果您需要查看访问日志和错误日志,请访问:
# Access Log
127.0.0.1 - - [14/Oct/2012:09:53:11 +0530] "GET /blog HTTP/1.1" 403 206
127.0.0.1 - - [14/Oct/2012:09:53:11 +0530] "GET /favicon.ico HTTP/1.1" 404 209
127.0.0.1 - - [14/Oct/2012:09:53:53 +0530] "GET / HTTP/1.1" 200 6935
127.0.0.1 - - [14/Oct/2012:09:53:53 +0530] "GET /app/blog/thumb.png HTTP/1.1" 404 216
# Error Log
[Sun Oct 14 09:53:11 2012] [error] [client 127.0.0.1] client denied by server configuration: C:/Wamp/vhosts/ptrl/praveen-kumar/blog
[Sun Oct 14 09:53:11 2012] [error] [client 127.0.0.1] File does not exist: C:/Wamp/vhosts/ptrl/apps/favicon.ico
[Sun Oct 14 09:53:53 2012] [error] [client 127.0.0.1] File does not exist: C:/Wamp/vhosts/ptrl/apps/app/blog, referer: http://apps.ptrl/
急切地等待一些帮助。如果需要,我准备提供更多信息。
<VirtualHost *:80>
ServerName apps.ptrl
DocumentRoot "C:/Wamp/vhosts/ptrl/apps"
ErrorLog "logs/apps-ptrl-error.log"
CustomLog "logs/apps-ptrl-access.log" common
# The alias to the blog!
Alias /blog "C:/Wamp/vhosts/ptrl/praveen-kumar/blog"
<Directory "C:/Wamp/vhosts/ptrl/praveen-kumar/blog">
allow from all
order allow,deny
AllowOverride All
</Directory>
<Directory "C:/Wamp/vhosts/ptrl/apps">
allow from all
order allow,deny
AllowOverride All
</Directory>
DirectoryIndex index.html index.htm index.php
</VirtualHost>
我可以访问该网站。物理链接现在正在运行。即,我可以打开http://apps.ptrl/blog/index.php
但不能http://apps.ptrl/blog/view-1.ptf
,它会被翻译为http://apps.ptrl/blog/index.php?page=view&id=1
。任何解决方案?
答案 0 :(得分:24)
注意,如果要在Alias之外的目录中创建DocumentRoot,则可能需要明确允许访问目标目录:
<VirtualHost *:80>
ServerName apps.ptrl
DocumentRoot "C:/Wamp/vhosts/ptrl/apps"
ErrorLog "logs/apps-ptrl-error.log"
CustomLog "logs/apps-ptrl-access.log" common
# Puts here, before Directory directive :)
Alias /blog "C:/Wamp/vhosts/ptrl/praveen-kumar/blog"
<Directory "C:/Wamp/vhosts/ptrl/apps">
allow from all
order allow,deny
AllowOverride All
</Directory>
</VirtualHost>
另请注意,即使在不区分大小写的文件系统上,URL路径(第一个别名部分)也区分大小写。
另外,请检查C:/Wamp/vhosts/ptrl/praveen-kumar/blog
目录的权限。
<强>参考强>