是相对于本地服务器路径或公共URL路径的目录



我知道 DocumentRoot是指服务器的本地路径(在磁盘上(,即用

<VirtualHost :80>
ServerName example.com
DocumentRoot /home/www/mysite1/

浏览http://example.com/foo/index.html将在服务器上访问/home/www/mysite1/foo/index.html

那么,我应该使用(有时似乎可以使用(:

<Directory "/">
Require all granted
</Directory>

(引用/,即服务器文件系统的根难道不是很奇怪吗?(

或应该将DocumentRoot复制/粘贴到Directory中:

DocumentRoot /home/www/mysite1/
<Directory "/home/www/mysite1/">
Require all granted
</Directory>

如果是这样,每次我们修改DocumentRoot时,必须将/粘贴复制到Directory很烦人,为什么需要此重复 of配置路径需要?没有任何方法可以说Require all granted 而无需复制路径?

请参阅Apache手册中的配置部分。

<Directory>确实是指文件系统路径。

您可以为整个网站指定规则,独立于文件系统上的位置,使用<Location>

我使用了此设置

<VirtualHost *:80>
    ServerName seminarium.loc
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/seminarium.loc/public
    <Directory /var/www/seminarium.loc/public>
            Options Indexes FollowSymLinks
            AllowOverride All
            Require all granted
    </Directory>
   ErrorLog /var/www/seminarium.loc/error.log
   CustomLog /var/www/seminarium.loc/access.log combined
</VirtualHost>

目录中的路径指定将应用选项的目录。自然要排除可能的冲突,希望指定文档根的路径,就好像有几个网站"/"他们会互相覆盖

最新更新