首页 > 解决方案 > Laravel 5.6 如何将 URL 作为 URL 参数传递?

问题描述

请任何人都可以帮我解决这个问题。

我的路线有以下 URL:

http://localhost:8000/notifications/e343ec2f-9e3d-08df90e7030b/read/http://localhost:8000/profile

我的路线是:

Route::get('/notifications/{id}/read/{redirect_to}', 'NotiController@readAndRedirect');

这是抛出 404。

我也尝试过以下方法:

Route::get('/notifications/{id}/read/{redirect_to}', 'NotiController@readAndRedirect')->where('redirect_to', 'some-regular-exp');

但它没有奏效。

知道如何实现这一目标吗?

问候,贾西

标签: javascriptphplaravel

解决方案


添加其他人在这里的建议,也许考虑而不是:

http://localhost:8000/notifications/e343ec2f-9e3d-08df90e7030b/read/http://localhost:8000/profile

让路线看起来像:

http://localhost:8000/notifications/e343ec2f-9e3d-08df90e7030b/read/profile

然后http://localhost:8000/在处理通知后在代码中添加该部分。通常,您不想重定向到完全不同的主机(我假设),这可能是一个安全漏洞(CSRF 等)。


推荐阅读