2014-09-06 65 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