WWW Preference
Generated .htaccess
# Force HTTPS
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# GZIP Compression
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/json
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE image/svg+xml
</IfModule>
# Browser Caching
<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 text/html "access plus 0 seconds"
ExpiresByType application/json "access plus 0 seconds"
</IfModule>
# Security Headers
<IfModule mod_headers.c>
Header always set X-Frame-Options "SAMEORIGIN"
Header always set X-Content-Type-Options "nosniff"
Header always set X-XSS-Protection "1; mode=block"
</IfModule>
# Block Directory Listing
Options -IndexesAbout .htaccess Generator
.htaccess Generator creates valid Apache configuration snippets for the most common web server tasks — URL redirects, HTTPS enforcement, security headers, browser caching rules, gzip compression, and access control — through a guided interface, without needing to write Apache directives from scratch.
How to Use .htaccess Generator
- 1
Select the rules you need
Check the options for the Apache directives you want to generate — such as HTTPS redirect, www to non-www, cache headers, or security headers.
- 2
Configure each rule
Fill in any required values such as redirect source and destination URLs, cache durations, or allowed IP addresses.
- 3
Copy and upload your .htaccess
Copy the generated configuration and paste it into your existing .htaccess file or create a new one in your site's root directory.
Common Use Cases
- Forcing HTTPS on all pages of a website by redirecting HTTP requests
- Setting browser cache expiry headers to improve page load speed
- Blocking specific IP addresses or requiring HTTP authentication on a directory
- Setting up clean URL rewrites to remove file extensions like .php or .html
Frequently Asked Questions
What is an .htaccess file?
Where do I place the .htaccess file?
Will this work on Nginx servers?
Related Tools
Robots.txt Generator
Generate robots.txt files to control search engine crawling.
Meta Tag Generator
Generate HTML meta tags for SEO, social sharing, and more.
Privacy Policy Generator
Generate a basic privacy policy for your website.
Password Generator
Generate strong, secure random passwords with customizable options.
UUID Generator
Generate universally unique identifiers (UUID v4) instantly.
QR Code Generator
Generate QR codes from any text or URL for easy sharing.