2014-09-06 67 views
9

我剛剛創建了我的服務器,我需要使用.htaccess文件,其中一個工作,另一個沒有工作......顯然,對於.htaccess工作,您需要啓用AllowOverride,所以我做了下:/etc/apache2/sites-available/default改變了這個:Ubuntu 12.04 AllowOverride全部引發內部服務器錯誤

<Directory /var/www/> 
    Options Indexes FollowSymLinks MultiViews 
    AllowOverride None 
    Order allow,deny 
    allow from all 
</Directory> 

要這樣:

<Directory /var/www/> 
    Options Indexes FollowSymLinks MultiViews 
    AllowOverride All 
    Order allow,deny 
    allow from all 
</Directory> 

當我重新啓動Apache我的整個網站現在拋出錯誤500 Internal Server Error

我的.htaccess文件包含這個:

RewriteEngine on 

# if a directory or a file exists, use it directly 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 

# otherwise forward it to index.php 
RewriteRule . index.php 

任何人有任何想法爲什麼?

+0

你有你的htaccess的東西嗎? – 2014-09-06 21:03:01

+0

是的,對不起,剛添加它! – Shepard 2014-09-06 21:04:11

+1

你是否啓用** mod_rewrite **?如果你的htaccess是空的呢? – 2014-09-06 21:04:57

回答

16

你的apache配置對我來說似乎很好。

你得到500 Internal Server Error這意味着你的htaccess現在被執行。
如果你沒有啓用mod_rewrite你會得到這樣的錯誤。

應該按預期工作一次mod_rewrite啓用。
另外,不要忘記添加RewriteBase(這將防止虛擬目錄未來的問題)

RewriteEngine on 
RewriteBase/

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule^index.php [L] 
+0

包含單詞RewriteBase的文件在哪裏? – Lunatikul 2018-02-07 12:26:54