Laravel重定向到使用url参数播放的新网址



>Laravel正在做一些不寻常的事情。我有一个网址如下:

https://www.sample-site.com/api/something/abcsafety/192

Laravel重定向到以下网址:

https://www.sample-site.com/api/something/abcsaf/safety

如果我在参数中传递任何其他内容,它可以工作。例如:

https://www.sample-site.com/api/something/abcsafe/192

工作正常。

我注意到它正在修剪 url 形式的 7 个字符(将 url 视为字符串(,如果安全关键字在 url 中,则在此之后附加/safety

我已经检查了中间件、控制器、应用程序服务提供商。在所有文件中添加 die 语句后,它仍然重定向。

它重定向并显示我的模具语句结果。

编辑:我的路由文件按要求

<?php
use IlluminateHttpRequest;
/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/
#paths
Route::middleware('allowedhost')->get('/something/flushall', 'SomethingController@flushAll');
Route::middleware('allowedhost')->post('/something/deletekeys', 'SomethingController@deleteSomethingKeys');
Route::middleware('allowedhost')->get('/something/{table}/{value}', 'SomethingController@updateSomething');
#end

我已经找到了问题的解决方案。这是因为中间件被添加到内核.php文件中。并调用了一个函数来替换包含安全的路由中的七个字符并执行该操作。

感谢您的帮助

最新更新