Last active
March 5, 2021 18:30
-
-
Save ericakfranz/5a78e5c534973dd134a7 to your computer and use it in GitHub Desktop.
WordPress .htaccess configuration file. Allows Forced SSL, Hide wp-config.php, Header ETags, GZIP Compression and Expires Caching.
This file contains hidden or 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
## BEGIN Force SSL ## | |
RewriteEngine On | |
RewriteCond %{HTTPS} !=on | |
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R=301,L] | |
## END Force SSL ## | |
## BEGIN WordPress ## | |
<IfModule mod_rewrite.c> | |
RewriteEngine On | |
RewriteBase / | |
RewriteRule ^index\.php$ - [L] | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteRule . /index.php [L] | |
</IfModule> | |
## END WordPress ## | |
## BEGIN Hide WordPress Config File ## | |
<files wp-config.php> | |
order allow,deny | |
deny from all | |
</files> | |
## END Hide WordPress Config File ## | |
## START Redirects ## | |
## Redirect 301 /old-page /new-page | |
## END Redirects ## | |
## BEGIN Disable ETags ## | |
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)(\.gz)?$"> | |
Header set Expires "Sun, 01 Jan 2016 20:00:00 GMT" | |
Header unset ETag | |
FileETag None | |
</FilesMatch> | |
## END Disable ETags ## | |
## BEGIN GZIP Compression ## | |
<IfModule mod_deflate.c> | |
<IfModule mod_headers.c> | |
Header append Vary User-Agent env=!dont-vary | |
</IfModule> | |
AddOutputFilterByType DEFLATE text/plain | |
AddOutputFilterByType DEFLATE text/html | |
AddOutputFilterByType DEFLATE text/json | |
AddOutputFilterByType DEFLATE text/xml | |
AddOutputFilterByType DEFLATE text/xsd | |
AddOutputFilterByType DEFLATE text/xsl | |
AddOutputFilterByType DEFLATE text/css | |
AddOutputFilterByType DEFLATE text/javascript | |
AddOutputFilterByType DEFLATE text/x-js | |
AddOutputFilterByType DEFLATE text/richtext | |
AddOutputFilterByType DEFLATE text/svg+xml | |
AddOutputFilterByType DEFLATE application/xml | |
AddOutputFilterByType DEFLATE application/xhtml+xml | |
AddOutputFilterByType DEFLATE application/rss+xml | |
AddOutputFilterByType DEFLATE application/javascript | |
AddOutputFilterByType DEFLATE application/x-javascript | |
AddType x-font/otf .otf | |
AddType x-font/ttf .ttf | |
AddType x-font/eot .eot | |
AddType x-font/woff .woff | |
AddType image/x-icon .ico | |
AddType image/png .png | |
BrowserMatch ^Mozilla/4 gzip-only-text/html | |
BrowserMatch ^Mozilla/4\.0[678] no-gzip | |
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html | |
<IfModule mod_mime.c> | |
# DEFLATE by extension | |
AddOutputFilter DEFLATE js css htm html xml | |
</IfModule> | |
</IfModule> | |
## END GZIP Compression ## | |
## BEGIN Expires Caching ## | |
<IfModule mod_expires.c> | |
ExpiresActive On | |
ExpiresByType image/jpg "access 1 year" | |
ExpiresByType image/jpeg "access 1 year" | |
ExpiresByType image/gif "access 1 year" | |
ExpiresByType image/png "access 1 year" | |
ExpiresByType text/css "access 1 month" | |
ExpiresByType application/pdf "access 1 month" | |
ExpiresByType text/x-javascript "access 1 month" | |
ExpiresByType application/x-shockwave-flash "access 1 month" | |
ExpiresByType image/x-icon "access 1 year" | |
ExpiresDefault "access 7 days" | |
</IfModule> | |
## END Expires Caching ## |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment