我试图取消我网站两个区域的 HTTP 标头中的“缓存控制”和“变化”指令:
- 主页
- /forum 页面和 /forum/ 下的页面
为此,我将以下代码(摘录)放在 .htaccess 文件中:
<LocationMatch "/">
<ifModule mod_headers.c>
Header set Cache-Control "no-cache"
Header set Vary: Cookie
</ifModule>
</LocationMatch>
<LocationMatch "/forum">
<ifModule mod_headers.c>
Header set Cache-Control "no-cache"
Header set Vary: Cookie
</ifModule>
</LocationMatch>
不幸的是,它破坏了网站(“致命错误”;它是一个基于 Wordpress 的网站)。
您会看到可以改进的地方,还是看到明显的错误?
代码放在文件的最顶部,所以它看起来像:
<LocationMatch "/">
<ifModule mod_headers.c>
Header set Cache-Control "no-cache"
Header set Vary: Cookie
</ifModule>
</LocationMatch>
<LocationMatch "/forum">
<ifModule mod_headers.c>
Header set Cache-Control "no-cache"
Header set Vary: Cookie
</ifModule>
</LocationMatch>
# BEGIN LSCACHE
# END LSCACHE
# BEGIN NON_LSCACHE
# END NON_LSCACHE
# BEGIN rlrssslReallySimpleSSL rsssl_version[4.0.9]
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
</IfModule>
# END rlrssslReallySimpleSSL
# 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
Options All -Indexes
[...]
您会在代码的延续中看到可能导致错误的内容吗?
非常感谢您的建议,LawK