Home > Backend Development > PHP Tutorial > Apache url重写,session丢失

Apache url重写,session丢失

WBOY
Release: 2016-06-06 20:39:00
Original
1385 people have browsed it

重写目的:
www.xx.com/user-100.html
重写到自定义名称的二级域名
user100.xx.com

目前发现的问题是访问这个www.xx.com/user-100.html,session正常
如果访问重写后的user100.xx.com,出现session丢失

因为有很多二级域名在项目间配合
因此php.ini中已经设置过session.cookie_domain=.xx.com以及session.auto_start=On
已经测试过直接二级域名之间的session可以正常获取以及设置
比如mai.xx.com

目前的URL规则文件如下:

<code>RewriteCond %{HTTP_HOST} ^(.*).xx.com$
RewriteCond %{HTTP_HOST} !www.xx.com$
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.*)$ /%{HTTP_HOST}/$1
RewriteRule ^/(.*).xx.com/$ /user.php?id=$1 [QSA,L]
</code>
Copy after login
Copy after login

希望有人碰到过此问题,谢谢解答!

回复内容:

重写目的:
www.xx.com/user-100.html
重写到自定义名称的二级域名
user100.xx.com

目前发现的问题是访问这个www.xx.com/user-100.html,session正常
如果访问重写后的user100.xx.com,出现session丢失

因为有很多二级域名在项目间配合
因此php.ini中已经设置过session.cookie_domain=.xx.com以及session.auto_start=On
已经测试过直接二级域名之间的session可以正常获取以及设置
比如mai.xx.com

目前的URL规则文件如下:

<code>RewriteCond %{HTTP_HOST} ^(.*).xx.com$
RewriteCond %{HTTP_HOST} !www.xx.com$
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.*)$ /%{HTTP_HOST}/$1
RewriteRule ^/(.*).xx.com/$ /user.php?id=$1 [QSA,L]
</code>
Copy after login
Copy after login

希望有人碰到过此问题,谢谢解答!

很顯然,「.xx.com」 是不包括 「xx.com」 的

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template