gpt4 book ai didi

apache - Htaccess - 如果未设置 env var 则跳过重定向

转载 作者:行者123 更新时间:2023-12-04 14:54:27 25 4
gpt4 key购买 nike

当特定环境变量为 时,我只想跳过使用“RewriteRule”完成的重定向。不是 由以前的“RewriteRule”设置。

这是我的示例,它不起作用。

RewriteEngine on
RewriteBase /

#
# if /internal ... set ENV var INTERNALAREA = true
#
RewriteRule ^internal(.*)$ - [E=INTERNALAREA:true]

#
# Redirect to /maintenance.php if not in internal area and not already at /maintenance.php
#
RewriteCond %{ENV:INTERNALAREA} !true
RewriteCond %{REQUEST_URI} !^/maintenance.php$
RewriteRule ^(.*)$ /maintenance.php [R=302,L]

#
# Default TYPO3 rewrites
#
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)\.(\d+)\.(php|js|css|png|jpg|gif|gzip)$ $1.$3 [L]

RewriteRule ^fileadmin/(.*/)?_recycler_/ - [F]
RewriteRule ^fileadmin/templates/.*(\.txt|\.ts)$ - [F]
RewriteRule ^typo3conf/ext/[^/]+/Resources/Private/ - [F]
RewriteRule ^(typo3/|t3lib/|fileadmin/|typo3conf/|typo3temp/|uploads/|favicon\.ico) - [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* index.php [L]

在维护 PHP 我有一个 phpinfo()输出 $_SERVER['REDIRECT_REDIRECT_INTERNALAREA'] = true .

我总是被重定向到 maintenance.php访问时 /internal/... .

我究竟做错了什么?

最佳答案

我已经找到了我的问题的答案。该问题源于以下问题:

When setting environment variables in Apache RewriteRule directives, what causes the variable name to be prefixed with "REDIRECT_"?

现在在所有其他规则之前设置以下内容时,一切都按预期工作:

RewriteCond %{ENV:REDIRECT_INTERNALAREA} (.+)
RewriteRule .* - [E=INTERNALAREA:%1]

下面是它的工作原理。它检查每次运行时是否已经设置了前缀 env var 并重新添加没有 REDIRECT_ 的环境变量。字首。

关于apache - Htaccess - 如果未设置 env var 则跳过重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49558294/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com