Apache's MultiViews option is a content negotiation feature that can cause confusing behavior: wrong files being served, unexpected 301 redirects, and conflicts with URL rewrite rules. This guide explains what MultiViews does, how to identify when it is causing problems, and how to disable it properly.
What MultiViews Does
MultiViews is part of Apache's mod_negotiation module. When enabled, if a client requests a URL like /about and no file named about exists, Apache searches the directory for files that match the base name — such as about.html, about.php, about.txt, or about.json — and serves the best match based on the client's Accept headers.
This was designed for multilingual websites and content type negotiation (serve HTML to browsers, JSON to API clients, etc.). In practice, it causes more problems than it solves for most modern websites.
Common Symptoms of MultiViews Problems
Wrong File Being Served
You have contact.php and contact.html in the same directory. When you visit /contact, Apache may serve the HTML file instead of the PHP file (or vice versa), depending on the client's Accept headers and Apache's internal scoring algorithm.
Unexpected 301 Redirects
You request /blog and instead of a 404, you get a 301 redirect to /blog.php with the extension appended. This reveals the server-side technology stack and can break clean URL structures.
.php Extension Appearing in URLs
Even with rewrite rules designed to remove file extensions, MultiViews can re-add them by redirecting extensionless URLs to the file with the extension. Your mod_rewrite rules and MultiViews compete for control.
Conflicts with mod_rewrite
MultiViews runs before mod_rewrite in Apache's request processing pipeline. This means MultiViews can match a file and rewrite the URL before your .htaccess rewrite rules even see the request. The result: your carefully crafted rewrite rules are bypassed entirely.
How to Disable MultiViews
Method 1: In .htaccess
Add this line to the .htaccess file in your document root:
Options -MultiViews
This disables MultiViews for the directory and all subdirectories. The minus sign (-) explicitly turns off the option. If you have other Options set, you can combine them:
Options -MultiViews +FollowSymLinks -Indexes
Important: For this to work, the AllowOverride directive in the VirtualHost or server config must include Options (or be set to All):
<Directory /var/www/html>
AllowOverride All
</Directory>
Method 2: In the VirtualHost Configuration
The more reliable approach is to disable MultiViews in the Apache VirtualHost configuration:
<VirtualHost *:80>
ServerName example.com
DocumentRoot /var/www/html
<Directory /var/www/html>
Options -MultiViews +FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
After editing the VirtualHost file, test and reload Apache:
sudo apache2ctl configtest
sudo systemctl reload apache2
Method 3: Disable mod_negotiation Entirely
If you have no need for content negotiation on the server at all, you can disable the entire module:
# On Debian/Ubuntu:
sudo a2dismod negotiation
sudo systemctl restart apache2
# Verify it is disabled:
apache2ctl -M | grep negotiation
This is the most thorough approach but affects all sites on the server.
When MultiViews Is Useful
Despite the problems it can cause, MultiViews has legitimate use cases:
- Language negotiation: If you have
page.en.html,page.fr.html,page.de.html, MultiViews can automatically serve the correct language version based on the client's Accept-Language header. - Format negotiation: An API endpoint that can serve the same resource as JSON, XML, or HTML based on the Accept header.
- Simple static sites: On a simple site with no framework or rewrite rules, MultiViews can provide extensionless URLs for free (requesting
/aboutservesabout.html).
However, for most PHP applications, CMS platforms, and any site using mod_rewrite, MultiViews should be disabled.
Verifying MultiViews Is Disabled
To confirm MultiViews is off, you can check what options are active for a given URL:
# Test by requesting a URL that would trigger MultiViews:
curl -I http://example.com/contact
# If MultiViews is active and contact.php exists, you may see:
# HTTP/1.1 301 Moved Permanently
# Location: http://example.com/contact.php
# If MultiViews is disabled and no rewrite rule matches:
# HTTP/1.1 404 Not Found
You can also check Apache's active configuration for a specific directory:
# Show the merged configuration for a path:
apache2ctl -t -D DUMP_RUN_CFG 2>&1 | grep -i multiviews
# Or check the full config:
apache2ctl -S
MultiViews vs mod_rewrite for Extensionless URLs
Both MultiViews and mod_rewrite can provide extensionless URLs, but mod_rewrite is the recommended approach because it gives you explicit control:
# In .htaccess — explicit rewrite rules (recommended):
Options -MultiViews
RewriteEngine On
# Remove .php extension:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+)$ $1.php [L]
This approach is predictable: you know exactly which files are served for which URLs. With MultiViews, the behavior depends on what files exist in the directory and the client's Accept headers, making it non-deterministic and difficult to debug.
For a complete guide on removing file extensions from URLs, see removing file extensions.
Summary
- MultiViews enables content negotiation — Apache guesses which file to serve based on the URL and Accept headers.
- It causes problems with mod_rewrite, can expose file extensions, and may serve the wrong file.
- Disable it with
Options -MultiViewsin.htaccessor your VirtualHost config. - Use explicit mod_rewrite rules for extensionless URLs instead.
- Only keep MultiViews enabled if you specifically need content negotiation (language or format).