Générateur .htaccess
Générez des fichiers de configuration Apache .htaccess avec des règles courantes pour les redirections, la mise en cache, la sécurité et les performances. Sélectionnez les règles dont vous avez besoin et copiez la configuration prête à l'emploi.
Redirections
Performance
Sécurité
Autre
.htaccess
# Generated by ToolBox Hub — https://toolboxhubs.com
Options -MultiViews
# Redirect HTTP to 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/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
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/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 text/html "access plus 1 day"
</IfModule>
# Disable Directory Listing
Options -Indexes
# Block access to .htaccess
<Files .htaccess>
Order allow,deny
Deny from all
</Files>Comment utiliser .htaccess
Placez le fichier .htaccess dans le répertoire racine de votre serveur web Apache (généralement public_html ou www). Assurez-vous que mod_rewrite et mod_headers sont activés.
Comment utiliser
Générez des fichiers de configuration Apache .htaccess avec des règles courantes pour les redirections, la mise en cache, la sécurité et les performances. Sélectionnez les règles dont vous avez besoin et copiez la configuration prête à l'emploi.
- 1Select your redirect rules: enable HTTP to HTTPS if your site has an SSL certificate (it should). Choose www to non-www or vice versa based on your canonical domain. Avoid enabling both www and non-www redirects simultaneously — pick one direction.
- 2Enable performance options: Gzip compression typically reduces HTML/CSS/JS size by 60-80%. Browser caching sets long expiry headers for images and assets so returning visitors don't re-download them. Both are safe to enable for almost any Apache site.
- 3Configure security rules: Disable directory listing to prevent visitors from browsing your file system. Block .htaccess access to hide your server configuration. Add security headers (X-Frame-Options, XSS Protection) for an extra layer of protection against common attacks.
- 4Enter your domain name in the config field if you're using non-www redirects or the hotlink protection rule — it needs to know which domain to allow. Click Copy and place the file in your web root (public_html, www, or wherever index.php/index.html lives).
Fonctionnalités
- 14 configurable rules across 4 categories — redirects, performance, security, and other directives
- Real-time generation — the .htaccess output updates instantly as you toggle rules
- Conflict detection — enabling both www→non-www and non-www→www simultaneously is prevented
- Custom domain and 404 page inputs — personalizes hotlink protection and error page rules