Skip to content

Instantly share code, notes, and snippets.

@gmmedia
Last active February 4, 2021 20:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gmmedia/fe3ef05442eb368a9bfd68a74c6e7deb to your computer and use it in GitHub Desktop.
Save gmmedia/fe3ef05442eb368a9bfd68a74c6e7deb to your computer and use it in GitHub Desktop.
Perfect WordPress .htaccess
# 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