Created
March 21, 2018 20:19
-
-
Save voneff/6b3c5ac61ee219fef96a948b5b6f73e6 to your computer and use it in GitHub Desktop.
WordPress plugin Cache Enabler: Bypass PHP execution
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
# BEGIN Cache Enabler | |
# Sources: | |
# https://fastwp.de/6687/ | |
# https://www.keycdn.com/support/wordpress-cache-enabler-plugin/ | |
# | |
# BEGIN Cache Enabler | |
<IfModule mod_rewrite.c> | |
RewriteEngine On | |
RewriteBase / | |
# set blog sub path | |
SetEnvIf Request_URI "^(.*)$" SUB_PATH=/wp-content/cache/cache-enabler/ | |
# set Cache Enabler path | |
SetEnvIf Request_URI "^(.*)$" CE_PATH=$1 | |
SetEnvIf Request_URI "^(/)index.php$" CE_PATH=$1 | |
<IfModule mod_mime.c> | |
# webp HTML file | |
RewriteCond %{ENV:CE_PATH} /$ | |
RewriteCond %{ENV:CE_PATH} !^/wp-admin/.* | |
RewriteCond %{REQUEST_METHOD} !=POST | |
RewriteCond %{QUERY_STRING} ="" | |
RewriteCond %{HTTP_COOKIE} !(wp-postpass|wordpress_logged_in|comment_author)_ | |
RewriteCond %{HTTP:Accept-Encoding} gzip | |
RewriteCond %{HTTP:Accept} image/webp | |
RewriteCond %{DOCUMENT_ROOT}%{ENV:SUB_PATH}%{HTTP_HOST}%{ENV:CE_PATH}index-webp.html.gz -f | |
RewriteRule ^(.*) %{ENV:SUB_PATH}%{HTTP_HOST}%{ENV:CE_PATH}index-webp.html.gz [L] | |
# gzip HTML file | |
RewriteCond %{ENV:CE_PATH} /$ | |
RewriteCond %{ENV:CE_PATH} !^/wp-admin/.* | |
RewriteCond %{REQUEST_METHOD} !=POST | |
RewriteCond %{QUERY_STRING} ="" | |
RewriteCond %{HTTP_COOKIE} !(wp-postpass|wordpress_logged_in|comment_author)_ | |
RewriteCond %{HTTP:Accept-Encoding} gzip | |
RewriteCond %{DOCUMENT_ROOT}%{ENV:SUB_PATH}%{HTTP_HOST}%{ENV:CE_PATH}index.html.gz -f | |
RewriteRule ^(.*) %{ENV:SUB_PATH}%{HTTP_HOST}%{ENV:CE_PATH}index.html.gz [L] | |
AddType text/html .gz | |
AddEncoding gzip .gz | |
</IfModule> | |
# webp HTML file | |
RewriteCond %{ENV:CE_PATH} /$ | |
RewriteCond %{ENV:CE_PATH} !^/wp-admin/.* | |
RewriteCond %{REQUEST_METHOD} !=POST | |
RewriteCond %{QUERY_STRING} ="" | |
RewriteCond %{HTTP_COOKIE} !(wp-postpass|wordpress_logged_in|comment_author)_ | |
RewriteCond %{HTTP:Accept} image/webp | |
RewriteCond %{DOCUMENT_ROOT}%{ENV:SUB_PATH}%{HTTP_HOST}%{ENV:CE_PATH}index-webp.html -f | |
RewriteRule ^(.*) %{ENV:SUB_PATH}%{HTTP_HOST}%{ENV:CE_PATH}index-webp.html [L] | |
# default HTML file | |
RewriteCond %{ENV:CE_PATH} /$ | |
RewriteCond %{ENV:CE_PATH} !^/wp-admin/.* | |
RewriteCond %{REQUEST_METHOD} !=POST | |
RewriteCond %{QUERY_STRING} ="" | |
RewriteCond %{HTTP_COOKIE} !(wp-postpass|wordpress_logged_in|comment_author)_ | |
RewriteCond %{DOCUMENT_ROOT}%{ENV:SUB_PATH}%{HTTP_HOST}%{ENV:CE_PATH}index.html -f | |
RewriteRule ^(.*) %{ENV:SUB_PATH}%{HTTP_HOST}%{ENV:CE_PATH}index.html [L] | |
# wp override | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteRule . /index.php [END] | |
</IfModule> | |
# END Cache Enabler |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment