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

iku*_*ris 11 php routes laravel laravel-4

如果打开这个网址,我的应用程序中有一个陌生的行为

http://example.com/Pd/Country/1
Run Code Online (Sandbox Code Playgroud)

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

在我的 routes

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

更新 我发现这个问题是在一些机器和浏览器不坚持会议,我有一些建议,以增加Session::save();Session::push('keyvalue',$keyvalue );,但仍无法正常工作

iku*_*ris 6

真正的问题

网址不同,即:设置的会话和未设置会话example.com的下一个请求http://www.example.com/.

解决方案

我不得不更改我的.htaccess文件,以便无论用户是否输入www.example.com,example.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]
Run Code Online (Sandbox Code Playgroud)