Knowledgebase

Using .htaccess Effectively Print

  • developersgitdeployment, developers, htaccess, errors, redirects, wordpress, ssl, domainrenewal, php, restore
  • 0

The per-directory configuration file.

WHAT IT CONTROLS

URL rewriting Redirects Access restrictions Custom error pages Compression and caching headers PHP settings, on some configurations Blocking specific files or user agents

WHERE IT GOES

In the directory it should affect. Rules in public_html apply site-wide; rules in a subdirectory apply there and below.

ORDER MATTERS

Rules are processed in order. A catch-all rewrite early in the file prevents later rules from being reached.

Place redirects above application blocks. In WordPress, above the BEGIN WordPress marker, or re-saving permalinks overwrites them.

BEFORE EDITING

Copy the file. A syntax error takes the entire site offline with a 500 error, and the file is frequently the last place people look.

TESTING

Load the site immediately after saving. If you get a 500, the file is the cause; restore your copy.

EXCLUDING THE SSL VALIDATION PATH

Add a condition excluding /.well-known/acme-challenge/ above your redirect rules, or certificate renewal fails.

PERFORMANCE

Rules are evaluated on every request. Keep the file short.


Was this answer helpful?
Back

Are you happy with your experience? Leave us a review on Trustpilot.


Trustpilot