我查了这里 , 这里 , 这里 , 这里 ,并在这里问这个问题之前。 我想我的搜索能力较弱。
我现在用的是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/
翘首等待一些帮助。 我已经准备好提供更多信息,如果需要的话。
更新#1:根据给出的指令改变VirtualHosts声明felipsmartins :
<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>
更新#2:另一个问题:
我能够访问该网站。 物理链接现在正在工作。 也就是说,我能打开http://apps.ptrl/blog/index.php
而不是http://apps.ptrl/blog/view-1.ptf
,它被翻译成http://apps.ptrl/blog/index.php?page=view&id=1
。 任何解决方案?