@@ -82,17 +82,23 @@ private function update_htaccess_header( $image_settings, $fonts_enabled ) {
82
82
83
83
if ( $ mirage_enabled || $ polish_enabled || $ fonts_enabled_flag ) {
84
84
$ rules = array (
85
+ '<IfModule mod_rewrite.c> ' ,
86
+ "\tRewriteEngine On " ,
87
+ '' ,
88
+ "\t# don’t flag any admin or API endpoints " ,
89
+ "\tRewriteCond %{REQUEST_URI} !/wp-admin/ [NC] " ,
90
+ "\tRewriteCond %{REQUEST_URI} !/wp-login \\.php [NC] " ,
91
+ "\tRewriteCond %{REQUEST_URI} !/wp-json/ [NC] " ,
92
+ "\tRewriteCond %{REQUEST_URI} !/xmlrpc \\.php [NC] " ,
93
+ "\tRewriteCond %{REQUEST_URI} !/admin-ajax \\.php [NC] " ,
94
+ '' ,
95
+ "\t# if we passed all those, set our CF_OPT flag " ,
96
+ "\tRewriteRule .* - [E=CF_OPT:1] " ,
97
+ '</IfModule> ' ,
98
+ '' ,
85
99
'<IfModule mod_headers.c> ' ,
86
- "\tHeader set Set-Cookie \"nfd-enable-cf-opt= {$ header_value }; path=/; Max-Age=86400; HttpOnly \" env=nfd_cf_opt " ,
100
+ "\tHeader set Set-Cookie \"nfd-enable-cf-opt= {$ header_value }; path=/; Max-Age=86400; HttpOnly \" env=CF_OPT " ,
87
101
'</IfModule> ' ,
88
- '# Exclude admin and API paths ' ,
89
- 'SetEnvIf Request_URI "^/wp-admin/" no_nfd_cf ' ,
90
- 'SetEnvIf Request_URI "^/wp-json/" no_nfd_cf ' ,
91
- 'SetEnvIf Request_URI "^/xmlrpc.php" no_nfd_cf ' ,
92
- 'SetEnvIf Request_URI "^/wp-login.php" no_nfd_cf ' ,
93
- 'SetEnvIf Request_URI "^/admin-ajax.php" no_nfd_cf ' ,
94
- '# Apply CF cookie on all non-admin, non-API requests ' ,
95
- 'SetEnvIf Request_URI ".*" nfd_cf_opt=!no_nfd_cf ' ,
96
102
);
97
103
}
98
104
0 commit comments