← Back to Tools

.htaccess Generator

Create Apache configuration rules for redirects, security, caching, and more.

Rule Builder

301/302 Redirect
Domain Redirect
HTTPS Redirect
Block IP Address
Block User Agent
Directory Listing
Prevent Hotlinking
Cache Control Headers
CORS Headers
Custom Error Pages
Clean URLs
Custom Rewrite Rule
Compression
Basic Authentication

Snippets Library

Click to add common .htaccess patterns:

Force SSL
Redirect all traffic to HTTPS
Remove index.php
Clean URLs without index.php
Block Access
Deny all file access
CORS All Origins
Allow requests from any origin
Gzip Compression
Compress HTML, CSS, JS
Cache Busting
Long-term caching with versioning
Hide .env Files
Block access to environment files
Disable PHP Upload
Prevent PHP execution in uploads
Security Headers
X-Frame-Options, X-Content-Type
Limit HTTP Methods
Allow only GET, POST, HEAD
Trailing Slash
Add/remove trailing slashes
WordPress Pretty URLs
Clean URLs for WordPress
Sitemap Rewrite
Rewrite sitemap.xml requests
Browser Caching
Cache control for all assets
Disable Directory Access
Prevent directory traversal
Robots.txt Rewrite
Dynamically serve robots.txt
API CORS Headers
CORS for REST APIs
Prevent SQL Injection
Block common SQL patterns
ETags
Enable/disable ETag headers
Character Set
Set default charset to UTF-8

Live Preview

📝

No rules added yet. Build your .htaccess configuration.

Generated Code

<!-- Your .htaccess content will appear here -->
ℹ️ Use this in your .htaccess file. Place it in your website's root directory.

Validation & Info

Ready to generate .htaccess configuration

Tips:

  • Place .htaccess in your root directory
  • Requires Apache with mod_rewrite enabled
  • Order matters - place more specific rules first
  • Test changes in a development environment
  • Enable .htaccess in httpd.conf (AllowOverride All)
  • Syntax errors can break your website
\xF0\x9F\x92\x99 Tip\xF0\x9F\x93\x9A Get Bundle \x244.99