Htaccess Builder
Build Apache .htaccess rules with a few clicks.
# Rewrites & redirects
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteRule ^old-page$ /new-page [L,R=301]
# Compress text assets with mod_deflate
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/json
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE image/svg+xml
</IfModule>
# Cache static assets for one year
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/svg+xml "access plus 1 year"
ExpiresByType image/webp "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
ExpiresByType font/woff2 "access plus 1 year"
</IfModule>
<IfModule mod_headers.c>
<FilesMatch "\.(jpg|jpeg|png|gif|svg|webp|css|js|woff2)$">
Header set Cache-Control "public, max-age=31536000, immutable"
</FilesMatch>
</IfModule>
How to use
- 1 Toggle HTTPS, www, gzip and caching options.
- 2 Add any custom redirects with from, to and a status code.
- 3 Review the generated .htaccess preview.
- 4 Copy the rules or download the .htaccess file.
About Htaccess Builder
The Htaccess Builder assembles a clean, ready-to-use Apache .htaccess file from a handful of common options, so you do not have to remember the exact RewriteCond and RewriteRule syntax every time.
Toggle a forced HTTPS redirect, choose whether to add or strip the www prefix for a single canonical host, switch on mod_deflate gzip compression for text assets, and add far-future cache headers for images, CSS, JavaScript and fonts.
You can also add any number of one-off redirects, each with its own from path, destination and status code (301 for permanent, 302 for temporary).
These directives are the bread and butter of shared hosting and traditional LAMP stacks: they improve SEO by enforcing a single canonical URL, speed up repeat visits through compression and caching, and let you preserve link equity when you move or rename pages.
Everything is generated locally as you toggle options, so no configuration ever leaves your browser.
Review the output, copy it, or download a file named .htaccess and drop it into your site root.
FAQ
Where does the .htaccess file go?
Place it in the document root of your site (or a subdirectory) on an Apache server with mod_rewrite, mod_deflate and mod_expires enabled.
Will this work on Nginx?
No. .htaccess is an Apache feature. Nginx uses a different server-block syntax and ignores .htaccess files.
What is the difference between a 301 and 302 redirect?
A 301 is permanent and passes SEO value to the new URL; a 302 is temporary and tells browsers the move may be reversed.