In short. On IONOS, the directory linked to a domain supplies the base for relative RewriteRule destinations.
Definition: On IONOS, a domain's linked webspace directory supplies the directory context for a relative rewrite destination.
RewriteBasedeclares the URL base that a per-directoryRewriteRuleuses when its substitution is relative.
Key facts
- IONOS says to specify
RewriteBaseat the beginning of.htaccessafter activatingRewriteEngine, and showsRewriteBase /in its rewrite rules guidance. - Apache describes
RewriteBaseas the base URL for per-directory rewrites. Its syntax isRewriteBase URL-path, and its context includesdirectoryand.htaccessin the Apache HTTP Server 2.4 module documentation. - With
/as the base, IONOS says the output path is the directory to which the domain is linked. The linked directory is shown in Domain Center under Domains > Manage Domains. - A rule whose destination is in the same directory uses no additional directory path in the rule, according to the IONOS example.
- A destination in another directory includes that directory path, such as
test/index.htmlfor a file in/test.
How does the linked directory set the base?
Apache's RewriteBase directive specifies the URL prefix used by per-directory RewriteRule directives that substitute a relative path. The directive therefore describes a URL path, while IONOS connects that base to the webspace directory linked to the domain. A domain linked to /test gives the rule a different base from a domain linked to the webspace root.
Apache lists the directive syntax as:
RewriteBase URL-path
The same documentation lists None as the default and gives directory, .htaccess as the context. It says that a relative substitution in per-directory context requires RewriteBase unless one of the documented exceptions applies, including a request and substitution underneath DocumentRoot or a mapping through Alias or mod_userdir in Apache HTTP Server 2.4.16 and later.
What changes for a relative rewrite destination?
IONOS separates rules that stay in the directory named by RewriteBase from rules that target another directory. For the same directory, its guidance says that no further directory path belongs in RewriteRule and that specifying the file with / is sufficient. Its example is:
RewriteEngine On
RewriteBase /
RewriteRule ^([a-z]+)\.html$ /index.php?$1 [R,L]
For a different directory, IONOS says the corresponding directory path must be specified. Its example loads index.html from /test for a non-existing HTML page:
RewriteEngine on
RewriteBase /
RewriteRule ^(.*)\.html$ test/index.html
IONOS also states that when the domain is already connected to /test, the /test specification in the rule is unnecessary because the directory is defined through RewriteBase. The placement of the domain link and the relative destination therefore needs to be read together.
How can you check the directory on IONOS?
IONOS directs you to Domain Center, then Domains > Manage Domains, to see which directory is linked to a domain. Compare that directory with the RewriteBase in the .htaccess file and with any relative destination in the rule. The page also says that .htaccess is recursive: it affects the directory where it is saved and its respective subdirectories.
The same IONOS guidance warns that rewrite rules can produce an HTTP 500 error after even a small error, including one incorrectly entered character, and describes that result as unrelated to a server failure. It recommends checking that .htaccess is in the correct directory when a rule has no effect.
Related terms
- Why can IONOS directory protection stop custom rewrite rules working?
- How can IONOS stop correcting misspelled file URLs automatically?
- How do I change a WordPress permalink structure?
FAQ
Is RewriteBase a filesystem path?
Apache defines the directive as a URL prefix for per-directory rules that use a relative substitution. IONOS describes the corresponding value through the directory linked to the domain, so the directive uses URL-path syntax such as / or /test.
What happens when the rule and base use the same directory?
IONOS says to omit additional directory paths from the rule and specify the file with /. Its same-directory example uses /index.php after RewriteBase /.
Why can a rewrite rule return HTTP 500?
IONOS says that rewrite rules can fail after one incorrectly entered character and that this error is not a server failure. It advises checking the .htaccess lines and the directory containing the file.
Sources
- IONOS Help, "Notes on Creating Rewrite Rules", null
- Apache HTTP Server, "mod_rewrite - Apache HTTP Server Version 2.4", null
Check how a page reads to answer engines. Open the GEO score analyzer