gpt4 book ai didi

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

转载 作者:可可西里 更新时间:2023-10-31 22:14:47 24 4
gpt4 key购买 nike

如果打开这个 url,我的应用程序会出现奇怪的行为

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

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

在我的路线

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

更新我发现问题是 session 在某些机器和浏览器中没有持续存在,我得到了一些建议在 Session::push('keyvalue',$ keyvalue );但还是不行

最佳答案

真正的问题

URL 不同,即:在 example.com 上设置的 session 和在 session 所在的 http://www.example.com/ 上完成的下一个请求没有设置 。

解决方案

我必须更改我的 .htaccess 文件,以便用户输入 www.example.comexample.com http://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]

关于php - Laravel 在某些机器 - 浏览器中返回 302,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34857318/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com