1
當你對這個問題的谷歌,可以發現很多類似的問題,但沒有單一的解決方案。cakephp 3.x和htaccess mod_rewrite讓我的會話消失
我有這個網站:
www.website.com
我的CakePHP 3.x的項目位於該目錄
www.website.com/project
會議在以前的項目中使用的,所以我要定製會話在app.php爲了訪問他們
'Session' => [
'defaults' => 'php',
'cookie' => 'PHPSESSID',
'timeout' => '20000',
'ini' => [
'session.cookie_domain' => '.website.com',
'session.save_path' => '/var/www/clients/client1/web/tmp/',
]
],
!!一切都很好瀏覽http://www.website.com/project它保持會議完好無損!
在htaccess的我做出/項目文件夾無形這樣:
http://www.website.com/project becomes http://www.website.com/
http://www.website.com/project/start becomes http://www.website.com/start
...
現在; http://www.website.com/和http://www.website.com/start正在失去我的會話
這是我的htaccess的文件:
Options +FollowSymLinks
RewriteEngine on
RewriteBase/
RewriteCond %{HTTP_HOST} !website.com$ [NC]
RewriteRule ^(.*)$ http://www.website.com/$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^website\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.website\.com$
RewriteCond %{HTTP_HOST} !^www\.website\.com$
RewriteRule (.*) http://www.website.com/$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
#rewrite previous project to root
RewriteRule ^/?$ "http\:\/\/www\.website\.com\/sys" [R=301,L]
#do nothing with these urls
RewriteCond %{REQUEST_URI} !^/portret/.*$
RewriteCond %{REQUEST_URI} !^/temp/.*$
RewriteCond %{REQUEST_URI} !^/tempcs/.*$
RewriteCond %{REQUEST_URI} !^/tempmail/.*$
RewriteCond %{REQUEST_URI} !^/tempsoc/.*$
RewriteCond %{REQUEST_URI} !^/tempzip/.*$
RewriteCond %{REQUEST_URI} !^/web/.*$
#disable project folder to make it nice
RewriteRule (.*) /project/$1 [QSA,L]
#fixing some pains-in-the-ass
Redirect 301 /FDM http://old-website/web/index1.php?ID=FDM
Redirect 301 /GM http://old-website.be/web/index1.php?ID=GM
Redirect 301 /FC http://old-website.be/web/index1.php?ID=FC
#set the root
DirectoryIndex project/search/start
一些調試信息:
session_get_cookie_params
Array ([lifetime] => 0 [path] => /project/ [domain] => .website.com [secure] => [httponly] => 1)
沒有在頁面上CakePHP的Debugkit Cookie的請求/項目
__unameb00ce0-152452f3c4a-10c277e4-12
PHPSESSID j1guvr5armlfpa7aa64aa9lfe1
_gaGA1.2.1776275125.1452677383
_gat1
與網頁上的CakePHP Debugkit Cookie的請求/項目
search Q2FrZQ==.MWQ3MzRhMWY3YWVmMzY0OGEzN2QwODFjMmY0MDE3NTdiOTI4OTQ5NDYxNmNhNmYwNzMyMjRmOTExNDA5NDJlOR+xldRH1lAaIbKGzowwWjtleNpkY/NYKZjft08u3Q8C
PHPSESSID 3amnr19lag1l0s7v5f20us4rq7
language Q2FrZQ==.ZDdjOWQ2NmI2ZDhiNWYzZGM2Zjg4MjRkM2NjMzRjMGRiMmM3NzM4MmEzMzRmZTFkNDI2NDhkY2U4MjBhOGZjM/ARPIqb98q5NwFN9JLi/HelqGCM6V3bsdCFlxxOkI/z
__unameb00ce0-152452f3c4a-10c277e4-12
_gat1
_gaGA1.2.1776275125.1452677383
你可以在你的問題中添加「session_get_cookie_params」的結果嗎? – DIDoS
我添加了一些更多的調試信息,您可以清楚地看到它創建了一個新的會話ID – Joost
爲什麼session_get_cookie_params路徑/ project /?你確定「/ var/www/clients/client1/web/tmp /」存在嗎? – DIDoS