Htaccess和php Session奇怪的结果似乎[L]不能正常工作


Htaccess and php Session weird results seems like [L] not working properly

我目前有这个URL mysite.com/en/store/storage要在SESSION变量中维护。只要我的网站上没有html无效文件,一切都会正确地返回。

这是我的htaccess文件得到的错误:

RewriteEngine On
rewritecond $1 '.(gif¦jpg¦css¦xml)$ [OR]
rewritecond %{REQUEST_FILENAME} -d [OR]
rewritecond %{REQUEST_FILENAME} -f 
RewriteRule (.*) - [S=3] 
RewriteRule ^(.*)/(.*)/(.*) index.php?lang=$1&type=$2&cat=$3 [L]
RewriteRule ^(.*)/(.*) index.php?lang=$1&type=$2 [L]
RewriteRule ^(.*) index.php?lang=$1&type=1 [L]

当我删除最后两行时,这一层的一切工作正常。当然,我需要将其他行应用到父级。

似乎[L]并没有停止htaccess,而是改变了我的SESSION变量,在php上是这样编码的:

<?php 
    session_start();
    echo $_SESSION["actualLink"]." -- test 1 ";
    $_SESSION["actualLink"] = $_GET["lang"]."/".$_GET["type"]."/".$_GET["cat"];
    echo "<img src='"mysite.com/images/wrongpath.jpg'"/>";
    echo $_SESSION["actualLink"]." test 2 ";
?>

整个htaccess的结果总是在页面重载时给出:

mysite.com/wrongimagepath.jpg test1—mysite.com/en/store/storage test2

删除最后两行后,结果如下:

mysite.com/en/store/storage test1—mysite.com/en/store/storage test2

问题是我需要这些行(在动态子文件夹上导致问题):

RewriteRule ^(.*)/(.*) index.php?lang=$1&type=$2 [L]
RewriteRule ^(.*) index.php?lang=$1&type=1 [L]

应用于如下页面:

mysite.com/en/store
mysite.com/en

谢谢你的帮助

试试这些规则:

RewriteEngine On
RewriteCond %{REQUEST_URI} '.(gif|jpe?g|js|css|xml)$ [NC,OR]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f 
RewriteRule ^ - [L] 
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/?$ index.php?lang=$1&type=$2&cat=$3 [L,QSA]
RewriteRule ^([^/]+)/([^/]+)/?$ index.php?lang=$1&type=$2 [L,QSA]
RewriteRule ^([^/]+)/?$ index.php?lang=$1&type=1 [L,QSA]