⚙️ Free Developer Tool

.htaccess Generator
Apache Configuration Made Easy

Generate .htaccess files with HTTPS redirect, Gzip compression, browser caching, bot blocking and more. Free, download ready.

Force HTTPS
Redirect all HTTP to HTTPS (301)
Enable Gzip Compression
Compress HTML, CSS, JS for faster loading
Browser Caching
Cache images 1 year, CSS/JS 1 month
Force WWW
Redirect non-www to www
Remove WWW
Redirect www to non-www
.htaccess
# Generated by DevLpers .htaccess Generator
# https://develpers.com/htaccess-generator

# Prevent Directory Browsing
Options -Indexes

# Force HTTPS
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# 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 image/svg+xml
</IfModule>

# 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 image/webp "access plus 1 year"
  ExpiresByType image/gif "access plus 1 year"
  ExpiresByType text/css "access plus 1 month"
  ExpiresByType application/javascript "access plus 1 month"
  ExpiresByType text/html "access plus 1 week"
</IfModule>

# Block Bad Bots
SetEnvIfNoCase User-Agent "AhrefsBot" bad_bot
SetEnvIfNoCase User-Agent "SemrushBot" bad_bot
SetEnvIfNoCase User-Agent "MJ12bot" bad_bot
SetEnvIfNoCase User-Agent "DotBot" bad_bot
SetEnvIfNoCase User-Agent "BLEXBot" bad_bot
<Limit GET POST HEAD>
  Order Allow,Deny
  Allow from all
  Deny from env=bad_bot
</Limit>

# Custom Error Pages
ErrorDocument 404 /404.html
ErrorDocument 403 /403.html
ErrorDocument 500 /500.html

Frequently Asked Questions

What is .htaccess?
.htaccess is a configuration file for Apache web servers. It allows you to control server settings at directory level including redirects, authentication, compression and more.
Where do I upload .htaccess?
Upload .htaccess to the root directory of your website (usually public_html or www folder). It affects that directory and all subdirectories.
Will .htaccess slow down my website?
.htaccess is read on every request which adds minimal overhead. However the performance gains from HTTPS redirects, Gzip and browser caching far outweigh this overhead.
Can .htaccess break my website?
Incorrect .htaccess rules can cause errors. Always backup your existing .htaccess before replacing it. Test on staging first if possible.

Built by Dev Zeeshan on DevLpers