.htaccess Generator
Generate Apache rewrite, caching, and security rules. Stop writing boilerplate by hand.
Generated .htaccess
# Generated by CodeItBro .htaccess tool
RewriteEngine On
# Force HTTPS
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Redirect non-www to www
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301]
# Enable gzip compression
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/javascript application/json image/svg+xml
</IfModule>
# Leverage browser caching
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
ExpiresByType text/html "access plus 1 hour"
</IfModule>Clean server rules in minutes
Whether you force HTTPS, normalize www, or add caching headers, this generator delivers ready-made .htaccess snippets with helpful documentation.
- • Pick a canonical domain
- • Enable gzip + browser caching
- • Block image hotlinking
Server Control
Rewrite Toolkit
HTTPS enforcement
Canonical redirects
How It Works
The .htaccess Generator runs entirely in your browser using JavaScript. Unlike other tools that send your data to a server, we process everything locally on your device. This guarantees 100% privacy and blazing fast speed.
- No server interaction – data never leaves your device
- Instant results since there is no network latency
- Works offline once the page is loaded
- Free to use with no usage limits
How to Use
Enter domain preferences
Choose your canonical domain (www vs non-www) and whether to force HTTPS.
Toggle performance/security
Add caching headers, gzip compression, or block hotlinking in one click.
Copy .htaccess snippet
Paste into the root of your Apache project or merge with existing rules.
Frequently Asked Questions
Where does .htaccess live?
Do these rules work on Nginx?
Will redirects stack?
Can I combine with existing .htaccess?
Do I need mod_deflate/mod_expires?
Related Tools
Lorem Ipsum Generator
Generate placeholder text.
Title Generator
Generate catchy titles for content.
Image Alt Tag Checker
Spot missing, empty, or duplicate image alt attributes for accessibility and SEO.
Sitemap Checker
Validate XML sitemaps, catch malformed loc entries, and verify HTTP status codes.
Meta Tag Generator
Generate optimized meta title, description, canonical, and social tags.
The .htaccess Generator is maintained by CodeItBro. We aim to provide the best free developer tools on the web. If you have feedback or suggestions, please visit our contact page.
