Why can IONOS directory protection stop custom rewrite rules working?

The Citead team, updated

In short. IONOS documents that its directory-protection function can overwrite an existing .htaccess file containing custom rewrite rules.

Definition: IONOS directory protection can stop custom rewrite rules when its control-panel function replaces an existing .htaccess file in the protected directory. Because Apache reads per-directory configuration from .htaccess, replacing that file can remove the RewriteEngine and RewriteRule directives that handled the site's URLs.

Key facts

  • IONOS says rewrite rules are defined in an .htaccess file on the server and that mod_rewrite is active by default on its web hosting servers. IONOS's rewrite troubleshooting documentation says the rewrite engine still has to be enabled.
  • IONOS states that its directory-protection function creates an .htaccess file in the corresponding directory and overwrites existing .htaccess files. The directory-protection documentation warns that this can impair website functionality.
  • Apache describes .htaccess as a per-directory configuration file whose directives apply to the directory containing it and its subdirectories. Apache's .htaccess tutorial also says that AllowOverride controls which directives are honored.
  • Apache defines a RewriteRule with a pattern, a substitution and optional flags. In the mod_rewrite introduction, the pattern in per-directory context is matched against the path relative to the directory containing the rule.

What does IONOS say happens?

IONOS's rewrite troubleshooting page names this specific failure mode. It asks whether a protected directory was created in the same directory with IONOS, then states that the function overwrites self-created .htaccess files and makes the rewrite rules ineffective. The same page recommends creating the protection yourself in .htaccess when this conflict applies.

The directory-protection page describes the other side of the operation: activating protection creates an .htaccess file in the corresponding directory. It says that existing files are overwritten and recommends using the function only when the directory does not already contain an .htaccess file. The documented backup options are downloading the file via FTP or renaming it first.

Why does replacing .htaccess affect rewriting?

An .htaccess file is a set of Apache directives attached to a directory. Apache says those directives apply to that directory and all of its subdirectories, so the file's location determines which requests it can affect. A replacement in that location can therefore change the configuration for the whole directory tree.

IONOS's basic rewrite sequence shows the directives that a custom file may contain:

RewriteEngine On
RewriteBase /
RewriteRule ^([a-z]+)\.html$ /index.php?$1 [R,L]

The first directive enables rewriting, the second sets the base directory used by the example, and the third maps matching HTML paths to the target. Apache describes the rule as three arguments, and says that a per-directory pattern is evaluated after the directory prefix has been removed. If the control-panel operation replaces the file, these custom directives are no longer the directives Apache reads from that path.

How can you check and repair the conflict?

Download or rename the existing .htaccess before enabling directory protection. After the panel operation, compare the file in the protected directory with that backup. IONOS also says that .htaccess is recursive, affecting its saved directory and respective subdirectories, and advises avoiding multiple nested .htaccess files because a lower-level file can affect higher-level rewrite rules.

If the custom directives are missing, restore the backed-up file and add the authentication directives to that file through the supported manual setup. Check that the file is in the directory used by the domain and that the rewrite engine is enabled. IONOS warns that a rewrite rule can fail without producing an HTTP 500 response, while a small syntax error can produce one.

The IONOS directory-protection page says that this control-panel function is no longer available for Web Hosting contracts purchased after 11 September 2024. The availability of the older panel workflow therefore depends on the contract date described by IONOS.

FAQ

Does the overwrite always produce an HTTP 500 response?

No single response is implied. IONOS says rewrite rules can stop taking effect without an HTTP 500 response, while an error in .htaccess can cause a 500 response.

What should be backed up before enabling protection?

Back up the existing .htaccess by downloading it through FTP or renaming it, as IONOS recommends. Keep the copy available for comparison or restoration after the panel action.

Can every IONOS Web Hosting contract use the panel function?

The IONOS page says the documented function is no longer available for contracts purchased after 11 September 2024. Check the contract date before relying on that workflow.

Sources

  1. IONOS Help, "Notes on Creating Rewrite Rules", undated
  2. IONOS Help, "Setting up protected directories in webspace", undated
  3. Apache HTTP Server, "Apache HTTP Server Tutorial: .htaccess files", undated
  4. Apache HTTP Server, "Apache mod_rewrite Introduction", undated

Check how a page reads to answer engines. Open the GEO score analyzer

Test a page and see what to fix first

The analysis usually takes less than 10 seconds and needs no account.

400,000+ pages scored in the public benchmark