.htaccess Generator
Toggle the rules you need. Get a complete, production-ready .htaccess file for your shared hosting — copy and paste into your site root.
Quick start
Pro tips
What every shared hosting tutorial forgets to mention.
💾 Always backup before editing
A single syntax error in .htaccess causes a 500 Internal Server Error for your entire site. Before making any changes, download a copy of the existing file. If you break it, you can restore via FTP or cPanel File Manager.
🔁 Rule order matters — a lot
Apache processes .htaccess rules from top to bottom and stops at the first match (if [L] flag is used). HTTPS redirect must come before www redirect. WordPress/Laravel rewrite rules must come after security rules. The generator outputs rules in the correct order.
⚡ .htaccess has a performance cost
Apache reads .htaccess on every request for every directory in the path. On a high-traffic site with deeply nested directories, this adds up. If you have access to the main VirtualHost config, put rules there with AllowOverride None and remove .htaccess entirely.
🏗 mod_rewrite must be enabled
URL rewriting (WordPress permalinks, Laravel routing) requires mod_rewrite to be enabled. On most shared hosts it's on by default. If rewriting isn't working, contact your host to confirm it's enabled.
🔒 Protect .htaccess itself
Add <Files .htaccess> Require all denied </Files> to prevent anyone from viewing your .htaccess rules directly via the browser — especially important if you have passwords or IP rules.
🧪 Test with cURL before assuming it works
Don\'t rely on your browser to test redirects — browsers cache 301s aggressively. Use curl -I http://yoursite.com to see the actual HTTP response headers, including the redirect location.
On shared hosting and hitting its limits?
.htaccess exists because shared hosting doesn't give you server config access. A VPS does.