Forum Moderators: phranque

Message Too Old, No Replies

Problem with mod_rewrite and the E= flag

Variable set with E= flag isn't being passed to SSI includes

         

calvinmicklefinger

5:32 pm on Jan 12, 2005 (gmt 0)

10+ Year Member



I have the following in my .htaccess file

********* begin cut and paste *********
DirectoryIndex cgi-bin/y/d.cgi/?index-IPP10000 index.htm
RewriteEngine on
Options +FollowSymlinks -Indexes
RewriteBase /
RewriteCond %{HTTP_REFERER}!^$
RewriteCond %{HTTP_REFERER}!^http://(www\.)?mydomain\.com/.*$ [NC]
RewriteRule \.(gif¦jpe?g¦png¦bmp)$ - [F,NC,L]
RewriteRule ^\.htaccess$ - [F]
RewriteRule ^([0-9]+)/([A-Za-z]+)$ cgi-bin/y/d.cgi/?$2-IPP$1 [E=MY_VAR:$1,L]
RewriteRule ^([0-9]+)$ cgi-bin/y/d.cgi/?index-IPP$1 [E=MY_VAR:$1,L]
ReWriteRule ^([A-Za-z]+)$ $1.shtml [E=MY_VAR:$1,L]
SetEnv A_NEW_VAR "Mudpie"
********* end cut and paste *********

and the following in the body of my HTML page named test.shtml

********* begin cut and paste *********
<body>
<!--#echo var="MY_VAR" --><br>
<!--#echo var="DOCUMENT_NAME" --><br>
<!--#echo var="A_NEW_VAR" --><br>
<!--#include file="textfile.txt" -->
</body>
********* end cut and paste *********

This is the resulting output when the page is rendered with the URL [mydomain.com...]

********* begin cut and paste *********
(none)
test.shtml
Mudpie
This is a test of inserting text
********* end cut and paste *********

My goal is to be able to get a variable from the RewriteRule, and using the "E=" flag, pass this variable to an SSI includes directive. This does not appear to be happening as can be seen when the SSI includes directive replaces the MY_VAR variable with "(none)" instead of "test" as used in the URL [mydomain.com...] which is parsed on the last RewriteRule line.

Note that the SetEnv variable is passed, but the .htaccess file doesn't seem to allow the use of variables that are not on the same line, so the SetEnv variable can only be a static variable.

Is there something I am missing? Is there something that needs to be changed in httpd.conf or elsewhere?

Is what I am trying to do possible? All the documentation I can find says it is.

Many thanks for any help you can provide.