.htaccess Generator | Free Apache Config Tool - SEOKit
Free .htaccess file generator. Create redirect rules, enable GZIP compression, set cache headers, block IPs, and configure Apache server easily.
Redirects
No redirects added yet.
# Force HTTPS
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Remove www
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
# GZIP Compression
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css
AddOutputFilterByType DEFLATE text/javascript application/javascript application/json
AddOutputFilterByType DEFLATE application/xml application/xhtml+xml
AddOutputFilterByType DEFLATE image/svg+xml
</IfModule>
# Browser Caching
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType text/html "access plus 1 hour"
ExpiresByType text/css "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
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 month"
ExpiresByType image/webp "access plus 1 year"
ExpiresByType font/woff2 "access plus 1 year"
ExpiresByType application/font-woff2 "access plus 1 year"
</IfModule>What is .htaccess Generator?
How to Use .htaccess Generator
Toggle the sections you need: Force HTTPS, Remove WWW, 301/302 redirects, GZIP compression, browser caching, block IPs, and custom error pages. Configure the details for each section. The .htaccess code is generated with comments explaining each rule. Click Copy to get the code and paste it into your .htaccess file.
How .htaccess Generator Works
Common Use Cases
- Force HTTPS and remove or add www prefix for canonical URLs
- Set up 301 redirects for URL changes or site migrations
- Enable GZIP compression to improve page speed
- Configure browser caching headers for faster load times
- Block malicious IPs and bots from accessing your site
Frequently Asked Questions
What is an .htaccess file?▼
.htaccess (hypertext access) is a configuration file used by Apache web servers. It allows you to make configuration changes on a per-directory basis without modifying the main server configuration.
Does .htaccess work with Nginx?▼
No, .htaccess files are specific to Apache web servers. If you use Nginx, you need to configure equivalent rules in your Nginx server block configuration file.
Can .htaccess affect site speed?▼
The .htaccess file itself adds a small amount of overhead since Apache checks for it on every request. However, the configurations it enables (caching, compression) typically far outweigh this overhead.
How do I upload the .htaccess file?▼
Use an FTP client or your hosting file manager to upload the .htaccess file to your website root directory. Make sure the filename starts with a dot (.) and has no file extension.
Related Tools
Robots.txt Generator
Free robots.txt generator. Create custom robots.txt files for your website with ...
Canonical URL Generator
Free canonical URL generator. Create rel=canonical link tags to prevent duplicat...
Redirect Chain Checker
Free redirect chain checker. Trace the full redirect path of any URL. See all 30...