【问题标题】:Ubuntu 12.04 AllowOverride All throws Internal Server ErrorUbuntu 12.04 AllowOverride All 引发内部服务器错误
【发布时间】:2014-10-31 12:26:54
【问题描述】:

我刚刚创建了我的服务器,我需要使用 .htaccess 文件,其中一个有效,另一个无效...显然要使 .htaccess 有效,您需要启用 AllowOverride,所以我在以下条件下做了:@987654321 @改变了这个:

<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

有人知道为什么吗?

【问题讨论】:

  • 你的 htaccess 里有东西吗?
  • 是的,抱歉刚刚添加了它!
  • 你启用了 mod_rewrite 吗?如果你的 htaccess 是空的怎么办?
  • 当然,我以为我做到了,谢谢!如果您提交答案,我会批准它!
  • 我相信这个问题属于 Serverfault 而不是 Stackoverflow。

标签: apache .htaccess ubuntu


【解决方案1】:

您的 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]

【讨论】:

  • 包含单词 RewriteBase 的文件在哪里?
猜你喜欢
  • 2017-11-10
  • 1970-01-01
  • 2012-06-30
  • 1970-01-01
  • 1970-01-01
  • 2021-10-25
  • 1970-01-01
  • 1970-01-01
  • 2014-08-27
相关资源
最近更新 更多