1

我有一种情况,我的图像与我的文档根目录位于同一级别。

所以我需要 /Users/jwindhall/Sites/gdw/my_app/images (www.example.local/images)

指向 /Users/jwindhall/Sites/gdw/images。

我一直在做:

其余的...

<VirtualHost *:80>
ServerAdmin example@whatever.com
DocumentRoot "/Users/jwindhall/Sites/gdw/my_app/"
ServerName www.example.local
ServerAlias www.example.local
<Directory "/Users/jwindhall/Sites/gdw/my_app">
   Options All Includes Indexes FollowSymLinks
   Order allow,deny
   Allow from all
   AllowOverride All
</Directory>
Alias /images /Users/jwindhall/Sites/gdw/images
</VirtualHost>

我究竟做错了什么?

4

2 回答 2

2

需要在您的Alias虚拟主机中定义(或直接在服务器配置中,但这可能不是一个好主意):

<VirtualHost *:80>
    ServerAdmin example@whatever.com
    DocumentRoot "/Users/jwindhall/Sites/gdw/my_app/"
    ServerName www.example.local
    ServerAlias www.example.local
    <Directory "/Users/jwindhall/Sites/gdw/my_app">
        Options All Includes Indexes FollowSymLinks
        Order allow,deny
        Allow from all
        AllowOverride All
    </Directory>

    Alias /images /Users/jwindhall/Sites/gdw/images
    <Directory "/Users/jwindhall/Sites/gdw/images">
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>
于 2012-12-27T01:19:55.247 回答
1

将别名放在 VirtualHost 中。此外,您不需要与 ServerName 相同的 ServerAlias。

 <VirtualHost *:80>
    ServerAdmin example@whatever.com
    DocumentRoot "/Users/jwindhall/Sites/gdw/my_app/"
    ServerName www.example.local
    <Directory "/Users/jwindhall/Sites/gdw/my_app">
       Options All Includes Indexes FollowSymLinks
       Order allow,deny
       Allow from all
       AllowOverride All
    </Directory>
    Alias /images /Users/jwindhall/Sites/gdw/images
 </VirtualHost>

如果这不起作用,你会得到什么错误?apache 用户是否有权访问图像目录?

于 2012-12-27T01:22:09.040 回答