【发布时间】:2023-03-24 12:07:02
【问题描述】:
我们使用 Laravel 5。为了将 http 连接重定向到 https,请使用中间件 HttpsProtocol。
namespace MyApp\Http\Middleware;
use Closure;
class HttpsProtocol {
public function handle($request, Closure $next)
{
if (!$request->secure() && env('APP_ENV') === 'prod') {
return redirect()->secure($request->getRequestUri());
}
return $next($request);
}
}
在我们的 4 个测试用例中,只有 1 个正确工作(最后一个重定向)。其他 3 案例中间件添加 url 额外 index.php。
http://www.aqualink.az/index.php ---> https://www.aqualink.az/index.php/index.php http://aqualink.az/index.php ---> https://aqualink.az/index.php/index.php https://www.aqualink.az/index.php ---> https://www.aqualink.az/index.php/index.php https://aqualink.az/index.php ---> https://aqualink.az/index.php
【问题讨论】:
-
我们使用相同的方法 Mr Purushotam Thakur