簡體   English   中英

Laravel 5.6如何通過URL作為URL參數?

[英]Laravel 5.6 How to pass URL as a URL parameter?

請任何人都可以幫助我解決這個問題。

我的路線下面有網址:

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');

但這沒有用。

任何想法如何實現這一目標?

問候,賈西

除了其他人在這里提出的建議外,也許考慮考慮而不是:

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等)。

看看urlencode

這是因為您的網址中不能包含特殊字符。

您應該始終對放置在url中的字符串進行urlencode 如果不是,則字符如/? 可能會破壞您的網址。

echo 'http://localhost:8000/notifications/e343ec2f-9e3d-08df90e7030b/read/' . urlencode('http://localhost:8000/profile');

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM