JIYIK CN >

Current Location:Home > Learning > NETWORK >

Apache's AllowOverride All doesn't do what you think

Author:JIYIK Last Updated:2025/03/17 Views:

I just had to set up an Apache server for a school project. Since I like to use .htaccess./batch files to set up rewrite rules and fiddle with some other options, I had to load some extra modules in addition to the standard batch processing.

phpinfo()You can easily check which modules are currently loaded using , as described in this article about enabling mod_rewrite in Apache .

Activating an Apache module is easy: just open the httpd.conf file in the /conf/ folder of your Apache installation and uncomment (or add) the appropriate lines. Comment lines always begin with a pound sign ( ).#

Basically, to load mod_negotiation(for multiviews) and mod_rewrite(for rewrite rules), we just need to add the following lines to httpd.conf :

LoadModule negotiation_module modules/mod_negotiation.so
LoadModule rewrite_module modules/mod_rewrite.so

So far, so good. Apache has been instructed to load the additional modules; we should now be able to use the and rewrite rules MultiViewsby defining them in a ./configure_modules file..htaccess

However, when I try to use Options +MultiViews, all I get is one of those infamous " 500 Internal Server Error " pages.

The error log said something along the lines of .htaccess: Option MultiViews not allowed here .

Google didn't really help in this case. At first, I could only find people with the same problem. #apache IRCI couldn't find any solutions until I really started looking through old logs.

It turns out that Apache has a default setting in httpd.conf that specifies settings that can be overridden by content written to a .htaccess file: AllowOverride. Our httpd.conf might contain something like this:

<Directory />
  Options FollowSymLinks
  AllowOverride All
  Order deny,allow
  Deny from all
</Directory>

Contrary to what we might think, Allparameter doesn't really mean "**[Allow overriding] all options** ", because it doesn't include MultiViewsthe options! The key here is the use of AllowOverride Options=All,MultiViews. Together with all the other directive groupings, this is the code we need:

<Directory />
  Options FollowSymLinks
  AllowOverride AuthConfig FileInfo Indexes Limit Options=All,MultiViews
  Order deny,allow
  Deny from all
</Directory>

For reprinting, please send an email to 1244347461@qq.com for approval. After obtaining the author's consent, kindly include the source as a link.

Article URL:

Related Articles

在 Apache2 中启用 PHP

Publish Date:2023/03/27 Views:204 Category:PHP

本文将教你如何使用 a2enmod、LoadModule 和符号链接在 Apache2 中启用 PHP。如果你遇到有关 PHP 的模块错误,我们将教你如何通过 apt-get 修复它。

Apache 的 AllowOverride All 并不像你想象的那样

Publish Date:2023/01/06 Views:197 Category:网络

我只需要为一个学校项目设置一个 Apache 服务器。 因为我喜欢使用 .htaccess 文件来设置重写规则并摆弄一些其他选项,所以除了标准批处理之外还必须加载一些额外的模块。 使用 phpin

从URL中移除 www.

Publish Date:2023/01/06 Views:157 Category:学无止境

如果你讨厌网站 URL 中的 www. 部分(就像我大约两个月前开始做的那样),你应该让其他人包括搜索引擎知道这一点。 这只是将通过 www. 访问的每个页面重定向到与其相等的 非www 的

php zookeeper常见问题解决方案

Publish Date:2017/03/13 Views:932 Category:PHP

本章承接上一章提出的php-zookeeper的问题以及原因来继续提出解决方案,一是修改php-zookeeper源码,再就是修改php代码。

Scan to Read All Tech Tutorials

Social Media
  • https://www.github.com/onmpw
  • qq:1244347461

Recommended

Tags

Scan the Code
Easier Access Tutorial