更新时间:2023-12-03 07:56:58
编辑:按@ AndrewR的回答启发(这在目前的形式却似乎没有为我工作 - 它看起来像第二条规则被应用于反正)与密钥工作的htaccess的唯一解决方案。
Inspired by @AndrewR's answer (which in its current form however didn't seem to work for me - it looks like the second rule gets applied anyway.) a .htaccess only solution that works with a secret key.
如果你遇到一个有效的模式,添加一个密钥来查询字符串。
If you encounter a valid pattern, add a secret key to the query string.
然后在页面重定向决定测试时,该密钥。
Then test for that secret key when deciding upon the page redirect.
RewriteEngine on
Options +FollowSymlinks
RewriteCond %{REQUEST_URI} ^/pattern$
RewriteRule .* /file.php?SUPER_SEKRIT_KEY [QSA]
RewriteCond %{QUERY_STRING} !SUPER_SEKRIT_KEY
RewriteCond %{REQUEST_URI} /file.php
RewriteRule .* /test/page-not-found.php [L,F]
使用当然是一个更复杂的密钥,仅供内部重定向!否则,用户将能够抓住密钥
Use a more complex key of course, and for internal redirects only! Otherwise, the user will be able to grab the secret key.