我刚刚创建了我的服务器,我需要使用 .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]
我是一名优秀的程序员,十分优秀!