Laravel在某些机器中返回302 - 浏览器


Laravel return 302 in some machine - browser

如果打开此网址,我的应用程序中有奇怪的行为

http://example.com/Pd/Country/1

在某些机器和浏览器中,我得到了预期的结果,响应代码200而其他机器返回302

在我的routes

Route::group(array('prefix' => 'Pd'), function() {
   Route::get('Country/{id}','CountryController@getAll');
});

更新我发现问题是会话未在某些机器和浏览器中持久化,我有一些建议在Session::push('keyvalue',$keyvalue );后添加Session::save();但仍然不起作用

真正的问题

url是不同的,即:在example.com上设置的会话和在未设置会话的http://www.example.com/上完成的下一个请求。

解决方案

我不得不更改我的.htaccess文件,以便用户类型是否www.example.comexample.comhttp://example.com/都将更改为http://www.example.com/

Options -MultiViews
RewriteEngine On
# remove index.php
RewriteCond %{THE_REQUEST} /index'.php [NC]
RewriteRule ^(.*?)index'.php$ /$1 [L,R=302,NC,NE]
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} !^www'.example'.com$ [NC]
RewriteRule ^ http://www.example.com%{REQUEST_URI} [R=301,L,NE]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]