gpt4 book ai didi

apache - Ubuntu 12.04 AllowOverride All 抛出内部服务器错误

转载 作者:太空宇宙 更新时间:2023-11-03 16:43:55 25 4
gpt4 key购买 nike

我刚刚创建了我的服务器,我需要使用 .htaccess 文件,其中一个可以工作而另一个没有......显然要使 .htaccess 工作,你需要启用 AllowOverride,所以我在下面做了:/etc/apache2/sites-available/default 改变了这个:

<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

有人知道为什么吗?

最佳答案

我觉得你的 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]

关于apache - Ubuntu 12.04 AllowOverride All 抛出内部服务器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25704707/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com