2016-02-19 23 views
10

允許我已經建立了虛擬主機像下面的AllowOverride不在這裏

<VirtualHost *:80> 
    DocumentRoot /var/www/html 
    ErrorLog ${APACHE_LOG_DIR}/error.log 
    CustomLog ${APACHE_LOG_DIR}/access.log combined 
    Options Includes 
    AllowOverride All 
</VirtualHost> 

但總是拋出我

AH00526: Syntax error on line 6 of /etc/apache2/sites-enabled/000-my-site.conf: 
AllowOverride not allowed here 

我有點困惑,因爲據我所知,是做

正確的地方

回答

25

這是因爲你必須把它放在<Directory>指令中。 .htaccess是每個目錄上下文,所以你必須明確地告訴Apache允許使用.htaccess的地方。

<VirtualHost *:80> 
    DocumentRoot /var/www/html 
    ErrorLog ${APACHE_LOG_DIR}/error.log 
    CustomLog ${APACHE_LOG_DIR}/access.log combined 
    Options Includes 
    <Directory "/var/www/html"> 
    AllowOverride All 
    </Directory> 
</VirtualHost> 
+0

你說得對。謝謝我忘記了這一點。我很長一段時間沒有使用apache – rkmax

+0

這真的很好一個兄弟 – Pearlboy