About .htaccess生成器
生成Apache .htaccess规则
Use this free online 生成器 tool to work faster without installing extra software. The interface is built for quick input, clear output, and straightforward results on desktop and mobile devices.
生成Apache .htaccess规则
Redirects
Custom Redirects
Security
Caching
Custom Error Pages
.htaccess Preview
# Force HTTPS
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Disable directory listing
Options -Indexes
# Protect .htaccess file
<Files .htaccess>
Order allow,deny
Deny from all
</Files>
# Block sensitive files
<FilesMatch "^\.(env|git|svn|htpasswd)">
Order allow,deny
Deny from all
</FilesMatch>
<FilesMatch "\.(sql|log|ini|conf)$">
Order allow,deny
Deny from all
</FilesMatch>
# Security Headers
<IfModule mod_headers.c>
Header set X-XSS-Protection "1; mode=block"
Header set X-Content-Type-Options "nosniff"
Header set X-Frame-Options "SAMEORIGIN"
</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/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType image/webp "access plus 1 year"
ExpiresByType image/svg+xml "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType application/x-font-woff "access plus 1 year"
ExpiresByType font/woff2 "access plus 1 year"
</IfModule>
# 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>生成Apache .htaccess规则
Use this free online 生成器 tool to work faster without installing extra software. The interface is built for quick input, clear output, and straightforward results on desktop and mobile devices.
This tool runs in your browser whenever possible, which keeps your inputs private and reduces unnecessary round-trips to the server.