开发者

Php sessions don't work after htaccess rewriterule

开发者 https://www.devze.com 2023-03-29 15:20 出处:网络
I have a booking system that i\'m trying to set up. I want to use the same functions for all customers. I have set up htaccess rewriterule to make it look like all the files are run from

I have a booking system that i'm trying to set up. I want to use the same functions for all customers. I have set up htaccess rewriterule to make it look like all the files are run from www.mydomain.com/web-book/customerX/index.php , but in fac开发者_Go百科t the files are located in the web-book folder. This is just for nice displaying and for giving each customer an easy link to their bookings.

RewriteRule ^([a-zA-Z]+)/([_a-zA-Z-]+)\.php$ /web-book/$2.php?site=$1

I'm also moving my css/images with the same technique working fine. javascripts working fine. Everything is good except the php Sessions.

THE PROBLEM: The php $_Session variables won't work, meaning i can't log in or do anything involving sessions. There must be something that i'm missing? I wan't my session vars to the accessible all over mydomain.com if possible???


Do you append PHP's Session-IDs to Querystring? If so, try to use the QSA flag:

RewriteRule ^([a-zA-Z]+)/([_a-zA-Z-]+)\.php$ /web-book/$2.php?site=$1 [QSA]

This will preserve any Get-Variable in Querystring, including Session IDs.


Check if don't have a conflicting php.ini file located at the root folder.

I unintentionally copied the php.ini file from my local server to the remote server and this prevent $_SESSION to be shared between my root directory and the sub directories.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号