nginx伪静态rewrite后php无法读取cookie的有关问题

WBOY
Release: 2016-06-13 12:07:15
Original
1351 people have browsed it

nginx伪静态rewrite后php无法读取cookie的问题
望回答问题的人细读我的问题描述。

主机引擎为 nginx
首先,确定rewrite规则是对的:rewrite ^/([0-9]+).htm /1.php last; 
作为测试,无论什么网页都映射到1.php,正常功能都实现,但是cookie读取出问题了。

<br /><?php<br />$value = "my cookie value";<br />setcookie("TestCookie2",$value, time()+3600*24);<br />print_r($_COOKIE);<br />?><br />
Copy after login


直接调用1.php,正常打印COOKIE没问题,调用1.htm,COOKIE打印为空,浏览器的COOKIE正常。

再测试以下两种
rewrite ^/([0-9]+).html /1.php last; 
rewrite ^/([0-9]+).shtml /1.php last; 
1.html,1.shtml都无法正常读取cookie

继续,任意
rewrite ^/([0-9]+).abc /1.php last; 
都可以正常读取cookie,与正常调用1.php 一样

判断应该是静态网页不传递cookie,而截包结果显示,浏览器的包头里还是有cookie的

求该怎么解决?
------解决思路----------------------
应该是你没有反映真实情况
------解决思路----------------------
调用1.htm,COOKIE打印为空

你在设置cookie的时候,设置下第四个参数试试。
------解决思路----------------------
目前我的解决方法是用JS读取,然后跳转到可以读取cookie的页面,这样对搜索引擎收录都没有影响

Related labels:
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!