How do you make mod_rewrite work with relative paths at Loopia?

To make mod_rewrite (Apache URL rewriting module) work correctly with relative paths in a .htaccess file on your Loopia web hosting, you first need to specify which folder the application or web page is based in. This is done with the RewriteBase directive, placed directly after RewriteEngine On in the .htaccess file.

Examples of RewriteBase usage

The value of RewriteBase must match the URL path where your .htaccess file lives, relative to the document root. Use the examples below as a starting point:

  • If the .htaccess file is located in the folder public_html/, use:
    RewriteBase /
  • If the .htaccess file is located in the folder public_html/subdirectory/, use:
    RewriteBase /subdirectory/

Further reading

More information about RewriteBase and mod_rewrite is available in the official Apache documentation:

Was this article helpful?

Related Articles