
An .htaccess file supplies per-directory Apache configuration when the server permits those overrides. It is not a configuration file that every web server reads.
Check whether overrides are allowed#
Apache's htaccess tutorial explains AllowOverride and why main-server configuration is preferable when you control it. On shared hosting, the allowed directives depend on the host. A disallowed directive can turn an otherwise working site into an error response.
Make one small change in a test copy, keep the previous file, and check the server's error log if the result is unexpected.
A custom missing-page document#
ErrorDocument 404 /404.htmlThe destination should exist and the missing URL should still return HTTP 404. Redirecting every missing page to the homepage hides the error and sends readers somewhere unrelated.
Treat redirects as routing changes#
Use the actual canonical host, verify the destination and test for loops. A redirect to HTTPS does not provision a certificate or fix an incorrectly configured proxy.
Rules copied from another host can contain its domain names, assumptions and obsolete directive syntax. Use the Apache 2.4 rewrite documentation for rules suited to your server, rather than copying a whole snippet collection into production.


