mod_rewrite rule and setenv

拥有回忆 提交于 2019-12-05 02:29:16

According to http://httpd.apache.org/docs/2.0/env.html the SetEnv is called after the RewriteRule. Therefore it seems to be impossible to use any variable set via SetEnv in a RewriteRule- or RewriteCond-statement.

Using SetEnvIf on the other hand is called before the RewriteRule and therefore Variables set there can be used in a RewriteRule- or RewriteCond-statement.

So something like the following should work:

SetEnvIf SERVER_PROTOCOL "HTTP.*" MY_SCRIPT=myScript.php
rewriteEngine on
RewriteRule ^(.*)$  %{ENV:MY_SCRIPT} [L]

Use %{ENV:MY_SCRIPT} instead of %{MY_SCRIPT}.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!