MAMP Apache Alias 始终相对于文档根映射

发布于 2024-12-16 18:41:28 字数 889 浏览 3 评论 0原文

我正在尝试在 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 以这种方式工作。有什么想法吗?

I'm trying to setup a virtual directory in Apache on MAMP.

This is what I'm putting in the httpd.conf file

  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's document root is set to the default /Applications/MAMP/htdocs and the path in the example above is meant to be absolute. But MAMP is trying to map the above path to:

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

I realized this after displaying the last few lines of apache's error log:

[Thu Nov 17 15:40:39 2011] [error] [client 127.0.0.1] File does not exist: /Applications/MAMP/htdocs/Users

Just ot be sure, I changes the path above to start with /Uxers (instead of /Users), and the change was reflected in the error log.

I'm almost sure from what I've researched online that what I expect is the correct behavior, but obviously I might be doing something wrong, or maybe there's some other obscure setting in MAMP's httpd.conf that is making apache work this way. Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

沙与沫 2024-12-23 18:41:28

所以..从这个SO问题我知道有同时使用 alias 和 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 文件的重写基础解决了我的问题(这首先让我想到了你的问题)

So.. from this SO question I got that there are some issues with using both alias and mod_rewrite. Which led me to this part of the Apache manual which states:

#
#  /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

Adding a rewrite base to the .htaccess file in the aliased directory solved my issue (which led me to your question in the first place)

指尖上得阳光 2024-12-23 18:41:28

我今天经历过这个。在我几乎抓狂之后(我真的必须完成一些工作),我发现 httpd-vhosts.conf 文件的包含内容在 MAMP 的默认安装中被注释掉了,因此,对我的 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
...

我用力捂住脸。这类似于电视未插入电源...

I went through this today. After nearly pulling all of my hair out (I really had to get something done work work), I found out found that the include for the httpd-vhosts.conf file was commented out in MAMP's default installation, so none of the (dozens of) troubleshooting changes to my httpd-vhosts.conf file were even taking:

...
# Virtual hosts
#Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
...
changed to 
...
# Virtual hosts
Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
...

I facepalmed so hard. This is akin to the TV not being plugged in...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文