Page 1 of 1

strange mod_rewrite and SESSION problem

Posted: Mon Dec 11, 2006 9:52 pm
by julian_lp

Code: Select all

in .htaccess
RewriteRule ^test_file/(.*).php /subfolder/test_file.php?arg1=blah&arg2=$1

test_file.php

<?php

	session_start();
	
       //this is the problematic line...
	echo '<img src="nonexistentpath/php_button.gif" alt="Get php"><br>';

	echo "variable $ _SESSION['xxxx'] = ".$_SESSION['xxxx'].'<br>';

	if (!isset($_SESSION['xxxx'])){
              $_SESSION['xxxx'] = 0;       
        }

       $_SESSION['xxxx']++;
	
?>

Now comes the weird beaviour:


If I call it without using the mod_rewrite, i.e

http://myip/subfolder/test_file.php

I get the expected results for the session var, which starts with 1 and after every page load adds its value 1 by 1


but, if I call it like this

http://myip/subfolder/test_file/whatever.php

$_SESSION['xxxx'] starts with 2, and then its values are 4, 6, 8 ....

Can anyone reproduce this kind of craziness, or is it just a problem with my server (local) ?

Posted: Mon Dec 11, 2006 11:52 pm
by m3mn0n
Try it with these flags on the same line as the rule: [QSA,L]

Posted: Tue Dec 12, 2006 12:21 am
by julian_lp
m3mn0n wrote:Try it with these flags on the same line as the rule: [QSA,L]
It didn't work for me :(

I'm more interested on some "explanation" for this beaviour rather than on a solution though, because the solution is simply not adding images that dont exist...