Last active
February 4, 2021 20:39
-
-
Save gmmedia/fe3ef05442eb368a9bfd68a74c6e7deb to your computer and use it in GitHub Desktop.
Perfect WordPress .htaccess
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# WordPress .htaccess von Jochen Gererstorfer | |
# https://j0e.org/wordpress-htaccess/ | |
# http zu https weiterleiten | |
<IfModule mod_rewrite.c> | |
RewriteEngine On | |
RewriteCond %{HTTPS} !=on | |
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] | |
</IfModule> | |
# Browser Caching | |
<IfModule mod_expires.c> | |
ExpiresActive On | |
ExpiresDefault "access 5 seconds" | |
ExpiresByType image/jpg "access 1 month" | |
ExpiresByType image/jpeg "access 1 month" | |
ExpiresByType image/gif "access 1 month" | |
ExpiresByType image/png "access 1 month" | |
ExpiresByType image/ico "access 1 month" | |
ExpiresByType image/x-icon "access 1 month" | |
ExpiresByType text/css "access plus 1 day" | |
ExpiresByType text/javascript "access 1 month" | |
ExpiresByType application/javascript "access 1 month" | |
ExpiresByType application/x-javascript "access 1 month" | |
ExpiresByType application/x-shockwave-flash "access 1 month" | |
</IfModule> | |
# Alternatives Caching | |
<IfModule mod_headers.c> | |
Header append Cache-Control "public" | |
Header append Vary Accept-Encoding | |
Header set Connection keep-alive | |
Header unset ETag | |
FileETag None | |
</IfModule> | |
# gzip Komprimierung | |
<IfModule mod_deflate.c> | |
SetOutputFilter DEFLATE | |
</IfModule> | |
# Kein Zugriff auf install.php | |
<files install.php> | |
Order allow,deny | |
Deny from all | |
</files> | |
# Kein Zugriff auf wp-config.php | |
<files wp-config.php> | |
Order allow,deny | |
Deny from all | |
</files> | |
# Kein Zugriff auf .htaccess und .htpasswd | |
<FilesMatch "(\.htaccess|\.htpasswd)"> | |
Order deny,allow | |
Deny from all | |
</FilesMatch> | |
# BEGIN WordPress | |
# The directives (lines) between "BEGIN WordPress" and "END WordPress" are | |
# dynamically generated, and should only be modified via WordPress filters. | |
# Any changes to the directives between these markers will be overwritten. | |
<IfModule mod_rewrite.c> | |
RewriteEngine On | |
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] | |
RewriteBase / | |
RewriteRule ^index\.php$ - [L] | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteRule . /index.php [L] | |
</IfModule> | |
# END WordPress |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment