环境如何标记ê作品在.htaccessmod-rewrite [英] How the Environment tag E works in .htaccess mod rewrite

查看:132
本文介绍了环境如何标记ê作品在.htaccessmod-rewrite的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个htaccess文件以下规则

I have the following rules in a htaccess file

RewriteEngine On
RewriteRule mytest.php test.php
RewriteCond %{QUERY_STRING} !done
RewriteRule (.*)  $1?done [E=TEST:itworks]

文件test.php的仅仅是

The file test.php is simply

<?php
echo "TEST = " . getenv('TEST'); 
?>

当我输入请求URI test.php的,环境变量TEST的定义,它呼应测试= itworks。但是,当我输入请求URI mytest.php,它也进入test.php的,但是环境变量的测试是没有定义,它呼应测试='。

When I enter the request uri test.php, the environment variable TEST is defined and it echoes 'Test = itworks'. However, when I enter the request uri mytest.php, it also goes to test.php, but the environment variable TEST is not defined and it echoes 'Test =' .

是预期的行为?如果是在我的环境中的错误,没关系。否则,也许人们可以使用简单的例子来向我解释它是如何工作的。

Is that the expected behavior? If it is a bug in my environment, never mind. Otherwise, perhaps one could use that simple case to explain to me how it works.

推荐答案

当你通过 mytest.php ,还有通过mod_rewrite的另一轮。

When you go through mytest.php, there is an additional round through mod_rewrite.

环境变量然后prefixed与重定向_ 。如果检查 REDIRECT_TEST ,你会看到所需的输出

The environment variables are then prefixed with REDIRECT_. If you check for REDIRECT_TEST, you will see the desired output

<?php
echo "TEST = " . getenv('TEST') . "/" . getenv('REDIRECT_TEST');

请参阅可用变量的一些细节。

这篇关于环境如何标记ê作品在.htaccessmod-rewrite的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆