TechBuzzPro

Apache Order Not Allowed Here htaccess Error Fix

· 6 min read · Apps & Browsers

In this article
  1. What Causes the “Order not allowed here” Error
  2. How to Fix It (Step-by-Step)
  3. What If You Can’t Change the Server Config?
  4. Why “Order” Specifically? The mod_access_compat Module
  5. Common Mistakes and Misconceptions
  6. How to Check the Error Log
  7. Preventing the Error in the Future
  8. Frequently Asked Questions

If you see “Order not allowed here” when loading a site that uses an .htaccess file, it means Apache’s AllowOverride directive is blocking the file’s directives. The fix is to enable AllowOverride All (or a more limited set) in the Apache configuration for that directory, then restart Apache. This article explains why the error occurs, how to fix it on common setups, and how to avoid it in the future.

What Causes the “Order not allowed here” Error

Apache processes .htaccess files only if the server configuration allows it. The AllowOverride directive (usually in a <Directory> block) controls which directives can appear in .htaccess. When AllowOverride is set to None (or does not include the specific directive you’re using), Apache logs an error and refuses to apply the file. The message “Order not allowed here” specifically refers to the Order directive (part of the older access-control module mod_access_compat), but you may see similar messages for other directives like RewriteEngine or Options.

Common scenarios:

  • Shared hosting: the host has set AllowOverride to None for security or performance.
  • Local development: the default Apache config on some systems has AllowOverride None.
  • After a server migration: the new config may not have the same overrides as the old one.

How to Fix It (Step-by-Step)

The exact steps depend on your server setup. Here are the most common cases:

1. If You Use a Linux Server with Apache (Debian/Ubuntu)

  1. Open the Apache configuration file: /etc/apache2/apache2.conf (or the site’s config in /etc/apache2/sites-available/).
  2. Find the <Directory> block for your web root (e.g., /var/www/).
  3. Change AllowOverride None to AllowOverride All (or a specific list like AllowOverride FileInfo AuthConfig).
  4. Save the file and run sudo systemctl reload apache2 (or sudo service apache2 reload).

2. If You Use a Linux Server with Apache (RHEL/CentOS/Fedora)

  1. Edit /etc/httpd/conf/httpd.conf (or the virtual host config).
  2. Locate the <Directory> block for your document root.
  3. Set AllowOverride All.
  4. Reload Apache: sudo systemctl reload httpd.

3. If You Use XAMPP or MAMP Locally

  1. Open the Apache config file: httpd.conf (in XAMPP: /Applications/XAMPP/xamppfiles/etc/httpd.conf on Mac, C:\xampp\apache\conf\httpd.conf on Windows).
  2. Search for AllowOverride (usually in a <Directory> block for htdocs).
  3. Change None to All.
  4. Restart Apache from the control panel.

4. If You Use cPanel or Plesk

Most shared hosts already allow .htaccess for the public_html directory. If you get the error, contact your host and ask them to enable AllowOverride for your domain’s document root. You cannot change this yourself unless you have root access.

What If You Can’t Change the Server Config?

If you don’t have access to the Apache configuration (e.g., on shared hosting), you have a few options:

  • Ask your hosting provider to enable AllowOverride – they may do it if you explain the need.
  • Move the directives that require override to the main server config (only possible if you have admin access).
  • Use a different method: for example, if you were using Order for access control, switch to Require (from mod_authz_core) which is often allowed even with limited overrides. But note: Require might also be blocked if AllowOverride is None.
  • If you’re using a CMS like WordPress, you can often move rewrite rules to the main server config (if you have access) or use a plugin that writes to .htaccess – but the plugin still needs AllowOverride to work.

Why “Order” Specifically? The mod_access_compat Module

The Order directive comes from mod_access_compat, an older module that provides access control based on hostnames or IP addresses. It was the standard way to allow/deny before Apache 2.4 introduced the Require directive. Many tutorials still use Order, but it’s deprecated and not recommended for new projects. On Apache 2.4+, you should use Require instead. However, even Require can be disallowed if AllowOverride is set to None.

If you see “Order not allowed here”, it means your .htaccess contains an Order directive (or a directive from mod_access_compat) and the server config doesn’t allow that module’s directives in .htaccess. The fix is either to enable AllowOverride or to replace the Order directive with a modern equivalent.

Common Mistakes and Misconceptions

  • Mistake: Editing the wrong <Directory> block. The error is for a specific directory. Make sure you’re editing the block that matches your web root or the directory containing the .htaccess file.
  • Mistake: Not restarting/reloading Apache. Changes to the main config require a reload or restart to take effect.
  • Misconception: AllowOverride All is a security risk. It does allow more directives, but it’s standard for many setups. If you’re worried, you can enable only the specific override types you need, like AllowOverride FileInfo AuthConfig.
  • Mistake: Using Order on Apache 2.4 when you should use Require. Even if you fix the override, Order may still cause warnings. Use Require for new code.
  • Misconception: The error appears in the browser. Actually, it appears in the Apache error log, not the browser. The browser may show a 500 Internal Server Error, but the specific message is in the log.

How to Check the Error Log

To confirm the exact error, check Apache’s error log. The location varies:

  • Debian/Ubuntu: /var/log/apache2/error.log
  • RHEL/CentOS: /var/log/httpd/error_log
  • XAMPP: /Applications/XAMPP/xamppfiles/logs/error_log (Mac) or C:\xampp\apache\logs\error.log (Windows)

Look for lines containing “Order not allowed here” or “.htaccess: Invalid command”. The log will show the exact line number in your .htaccess that caused the problem.

Preventing the Error in the Future

  • Use modern directives (Require instead of Order).
  • If you control the server, set AllowOverride to the minimum needed (e.g., FileInfo for rewrites, AuthConfig for auth).
  • Test .htaccess changes locally with a server that has overrides enabled.
  • Document your server configuration so you know what’s allowed.

Frequently Asked Questions

Can I fix “Order not allowed here” without restarting Apache?

No, changes to AllowOverride in the main config require a reload or restart of Apache. However, if you’re only editing the .htaccess file itself, no restart is needed – changes take effect immediately (but the error will persist until you fix the config or remove the offending directive).

Why does my .htaccess work on one server but not another?

Because the other server has a different AllowOverride setting. The default on many shared hosts is All for the public_html directory, but some hosts set it to None for performance or security. Also, different Apache versions may have different default modules enabled.

What does “AllowOverride All” actually allow?

It allows all directives that are permitted in .htaccess context. This includes RewriteEngine, Options, AuthConfig, FileInfo, Indexes, and others. It does not allow directives that are only valid in server or virtual host context.

Is there a way to use .htaccess without changing AllowOverride?

No, if AllowOverride is None, Apache will ignore the .htaccess file entirely (and log an error). You must change the server config or move the directives to the main config.

What if I get “Invalid command 'Order'” instead?

That error means the mod_access_compat module is not enabled. You can enable it (e.g., sudo a2enmod access_compat on Debian/Ubuntu) or replace Order with Require directives. The latter is recommended for Apache 2.4+.

Can I use a .htaccess file in a directory that’s not the web root?

Yes, .htaccess applies to the directory it’s in and all subdirectories. The AllowOverride setting for that directory must allow it. If you get the error, check the <Directory> block for that specific path.