- SEO
- .htaccess Generator
.htaccess Generator
Apache htaccess erstellen
Grundeinstellungen
Sicherheit
Leistung
Fehlerseiten
Weiterleitungen
.htaccess
# Generated by ToolNest .htaccess Generator
#
# 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 [L,R=301]
# Default index file
DirectoryIndex index.php
# Disable directory listing
Options -Indexes
# Protect .htaccess
<Files .htaccess>
Order allow,deny
Deny from all
</Files>
# Block bad bots
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} (bot|crawl|slurp|spider|mediapartners) [NC]
RewriteCond %{HTTP_USER_AGENT} !(googlebot|bingbot|yandex|duckduckbot) [NC]
RewriteRule .* - [F,L]
# Enable Gzip compression
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css
AddOutputFilterByType DEFLATE text/javascript application/javascript application/x-javascript
AddOutputFilterByType DEFLATE application/json application/xml application/xhtml+xml
AddOutputFilterByType DEFLATE image/svg+xml font/ttf font/otf
</IfModule>
# Browser caching
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType text/html "access plus 3600 seconds"
ExpiresByType text/css "access plus 2592000 seconds"
ExpiresByType text/javascript "access plus 2592000 seconds"
ExpiresByType application/javascript "access plus 2592000 seconds"
ExpiresByType image/jpeg "access plus 2592000 seconds"
ExpiresByType image/png "access plus 2592000 seconds"
ExpiresByType image/gif "access plus 2592000 seconds"
ExpiresByType image/webp "access plus 2592000 seconds"
ExpiresByType image/svg+xml "access plus 2592000 seconds"
ExpiresByType font/woff2 "access plus 31536000 seconds"
</IfModule>
# Custom error pages
ErrorDocument 404 /404.html
ErrorDocument 500 /500.htmlHäufig gestellte Fragen
Was ist .htaccess?
.htaccess ist eine Apache-Konfigurationsdatei, die URL-Weiterleitungen, Sicherheit, Caching und Zugriffsregeln für Verzeichnisse und Dateien Ihrer Website steuert.
Brauche ich .htaccess für alle Server?
Nein, .htaccess ist Apache-spezifisch. Nginx verwendet nginx.conf, IIS verwendet web.config. Viele moderne Hosts nutzen Nginx, prüfen Sie Ihren Servertyp.
Wofür wird .htaccess häufig verwendet?
URL-Weiterleitungen (www zu ohne-www), HTTPS erzwingen, benutzerdefinierte Fehlerseiten, Hotlink-Schutz, Passwortschutz, Caching-Header, Bots blockieren.