MAMP Apache别名总是相对于文档根目录映射

3

我正在尝试在MAMP上的Apache中设置虚拟目录。

这是我要放入httpd.conf文件中的内容:

  Alias /app /Users/ernesto/Developer/App/webroot
  <Directory /Users/ernesto/Developer/App/webroot>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    Allow from all
  </Directory>

MAMP的文档根目录默认设置为/Applications/MAMP/htdocs,上面的路径是绝对路径。但是MAMP试图将上面的路径映射到:

/Applications/MAMP/htdocs/Users/ernesto/Developer/App/webroot

我在显示Apache错误日志的最后几行后意识到这一点:
[Thu Nov 17 15:40:39 2011] [error] [client 127.0.0.1] File does not exist: /Applications/MAMP/htdocs/Users

为了确保,我将上面的路径更改为以/Uxers开头(而不是/Users),并且错误日志中反映了这个更改。

从我在网上研究的内容来看,我几乎可以确定我期望的行为是正确的,但显然我可能做错了什么,或者MAMP的httpd.conf中可能有其他模糊的设置使得Apache以这种方式工作。任何想法?

2个回答

3

所以..从这个SO问题中,我得知同时使用别名和mod_rewrite存在一些问题。这让我想起了Apache手册的这一部分,其中指出:

#
#  /abc/def/.htaccess -- per-dir config file for directory /abc/def
#  Remember: /abc/def is the physical path of /xyz, i.e., the server
#            has a 'Alias /xyz /abc/def' directive e.g.
#

RewriteEngine On

#  let the server know that we were reached via /xyz and not
#  via the physical path prefix /abc/def
RewriteBase   /xyz

#  now the rewriting rules
RewriteRule   ^oldstuff\.html$  newstuff.html

在别名目录的.htaccess文件中添加重写基础路径解决了我的问题(这也导致我首先看到了你的问题)。

这个有效了,谢谢!RewriteBase 的默认值是 <physical-directory-path>,但从逻辑上讲应该是 Alias url。现在必须在每个 .htaccess 文件中显式地指定 RewriteBase 才能纠正这个问题。显然这是 mod_rewrite 中的一个bug... - Jocelyn

0
今天我遇到了这个问题。在几乎把所有头发都拔光之后(我真的必须完成一些工作),我发现MAMP默认安装中httpd-vhosts.conf文件的包含被注释掉了,因此我的httpd-vhosts.conf文件进行的(数十次)故障排除更改甚至都没有生效。
...
# Virtual hosts
#Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
...
changed to 
...
# Virtual hosts
Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
...

我真的很无语。这就像电视没有插上电源一样...


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接