Generators
.htaccess Generator
Build Your .htaccess
Quick Templates
Basic WordPress
Standard WordPress .htaccess rulesStatic Website
Optimized for static HTML sitesSecurity Focused
Maximum security settingsPerformance Optimized
Focus on speed and cachingBasic Settings
Custom Error Pages
Redirect Rules
Tool features
4 features
Complete Configuration
Generate comprehensive .htaccess files with all features
Security Rules
Built-in security headers and protection rules
Performance Optimization
Compression and caching rules for faster loading
URL Management
Redirects, rewrites, and URL canonicalization
What is .htaccess & how it works
.htaccess is a per-directory configuration file for the Apache web server (and LiteSpeed, which reads the same syntax). Placed in your site's document root, it lets you add redirects, rewrite rules, compression, caching and security headers without editing the main server config.
Apache reads the file on every request, so changes take effect immediately with no restart, but a single syntax error returns a 500 Internal Server Error for the whole directory. Nginx does not read .htaccess at all; the same rules must be translated into its server block.
mod_rewrite
The Apache module behind RewriteRule redirects such as forcing HTTPS or www.
mod_deflate / mod_expires
Modules that add GZIP compression and browser-cache lifetimes.
AllowOverride
Main-config setting that must permit .htaccess files to take effect.
How to use this tool
1
Pick the rules
Turn on Force HTTPS, add or remove www, GZIP compression, browser caching, security headers and hotlink protection as needed.
2
Add redirects and pages
Enter any From/To redirects, custom error pages and the default index file.
3
Generate the file
Generate the rules and review them before copying.
4
Upload and test
Back up any existing .htaccess, upload the new one to the document root, and test the site straight away.
Related tools
3 tools
Robots.txt Generator
Generate robots.txt files to control web crawler access and search engine indexing
HTTP Header Checker
Analyze HTTP response headers for any website or URL with detailed header information
Secure Header Checker
Check security headers like CSP, HSTS, X-Frame-Options, and more with security scoring
Frequently asked questions
5 Q&A
Apache hit a syntax error or a directive from a module that is not enabled. Restore your backup, then check the Apache error log for the exact line. Wrapping module-specific rules in
<IfModule> blocks avoids errors when a module is missing.The main Apache config must allow them with
AllowOverride All (or the specific override types) for that directory, and the rewrite rules need mod_rewrite enabled. On Nginx, .htaccess is never read.If your host does not already redirect HTTP to HTTPS, yes: use a 301 redirect so browsers and search engines move to the HTTPS URLs. Add HSTS once every page works over HTTPS.
Slightly, because Apache checks for and parses the file on every request. On a server you control, moving the rules into the main config and disabling overrides is marginally faster.