上層目錄中的 .htaccess 被忽略

上層目錄中的 .htaccess 被忽略

我在 /var/www/html/htc 目錄中有一個 .htaccess 文件,其中包含 bookmatic.net 的特定規則,另一個 .htaccess 檔案包含 /var/www/html 中所有網域的一般規則

存取 bookmatic.net 時,/htc 中的 .htaccess 檔案運作良好,但 /html 中的檔案會被忽略。有人可以幫忙嗎?

httpd.conf 中的 bookmatic.net 規格如下:

<VirtualHost *:443>
    ServerName bookmatic.net
    ServerAlias *.bookmatic.net
    DocumentRoot /var/www/html/htc
    AllowEncodedSlashes On

    <Directory /var/www/html/htc>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Require all granted
        LimitRequestBody 25000000
        LimitXMLRequestBody 25000000
    </Directory>

    RewriteEngine on
</VirtualHost>

答案1

AllowOverride All.htaccess是告訴 Apache 在文件中尋找更多配置的指令。

虛擬主機告訴 Apache 在 中及更深層次中尋找.htaccess文件/var/www/html/htc,以免它覆蓋.htaccess中的文件/var/www/html

解決這個問題的一種方法是創建另一個像這樣的區塊(httpd.conf如果更有意義的話,可能在這個虛擬主機中而不是在這個虛擬主機中):

<Directory /var/www/html>
     AllowOverride All
</Directory>

答案2

AllowOverride All<Directory /var/www/html/htc>.我想這是不允許的/var/www/html。你可以嘗試:

<Directory /var/www/html>
    AllowOverride All
</Directory>

相關內容