โš™๏ธ

.htaccess Generator

Generate .htaccess rules for HTTPS, redirects, GZIP, caching, IP blocking and more

Share:
Force HTTPS
Redirect all HTTP traffic to HTTPS
Custom 404 Page
Set custom error pages
Block IP Addresses
Block specific IPs from accessing your site
Enable GZIP Compression
Compress text-based files for faster loading
Set Cache Headers
Browser caching for static assets
Password Protect Directory
Require username/password for access
Block Hotlinking
Prevent other sites from embedding your images
# Force HTTPS
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# Redirect www to non-www
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]

# Enable GZIP Compression
<IfModule mod_deflate.c>
  AddOutputFilterByType DEFLATE text/html text/plain text/xml
  AddOutputFilterByType DEFLATE text/css text/javascript
  AddOutputFilterByType DEFLATE application/javascript application/json
  AddOutputFilterByType DEFLATE application/xml application/xhtml+xml
  AddOutputFilterByType DEFLATE image/svg+xml
</IfModule>

# Set Cache Headers
<IfModule mod_expires.c>
  ExpiresActive On
  ExpiresByType image/jpeg "access plus 30 days"
  ExpiresByType image/png "access plus 30 days"
  ExpiresByType image/gif "access plus 30 days"
  ExpiresByType image/svg+xml "access plus 30 days"
  ExpiresByType text/css "access plus 7 days"
  ExpiresByType application/javascript "access plus 7 days"
  ExpiresByType text/html "access plus 1 hour"
</IfModule>

<IfModule mod_headers.c>
  <FilesMatch "\.(ico|jpe?g|png|gif|svg|webp|css|js|woff2?)$">
    Header set Cache-Control "max-age=2592000, public"
  </FilesMatch>
</IfModule>

About .htaccess Generator

.htaccess Generator is a free online tool available on SabTools.in. Generate .htaccess rules for HTTPS, redirects, GZIP, caching, IP blocking and more. This tool is completely free to use, requires no signup, and works instantly in your browser. Your data stays private as all calculations happen on your device.

How to use .htaccess Generator?

  1. Enter the required values in the input fields above
  2. The results will be calculated automatically in real-time
  3. You can copy or share the results as needed

Why use SabTools.in?

  • 100% free โ€” no signup, no limits, no hidden fees
  • Lightning fast โ€” runs instantly in your browser
  • Privacy first โ€” your data never leaves your device
  • Mobile friendly โ€” works on any phone, tablet or computer
  • Made for India โ€” Indian number formats, GST, EMI & more

Frequently Asked Questions