Please any one could help me figure this out.
I have below URL for my route:
http://localhost:8000/notifications/e343ec2f-9e3d-08df90e7030b/read/http://localhost:8000/profile
And my route is:
Route::get('/notifications/{id}/read/{redirect_to}', 'NotiController@readAndRedirect');
This is throwing 404.
I have also tried with following:
Route::get('/notifications/{id}/read/{redirect_to}', 'NotiController@readAndRedirect')->where('redirect_to', 'some-regular-exp');
But it didn't worked.
Any idea how to achieve this?
Regards, Jassi
Adding to what others are suggesting here, perhaps consider instead of:
http://localhost:8000/notifications/e343ec2f-9e3d-08df90e7030b/read/http://localhost:8000/profile
To have the route look like:
http://localhost:8000/notifications/e343ec2f-9e3d-08df90e7030b/read/profile
And then prepend the http://localhost:8000/
part in your code after handling the notification. Normally you don't want to redirect to a completely different host (I would assume), and it's potentially a security vulnerability (CSRF and such).
Take a look at urlencode .
It's because you can't have special characters in your URL.
You should always urlencode
strings that are put in an url. If not, characters like /
or ?
might break your url.
echo 'http://localhost:8000/notifications/e343ec2f-9e3d-08df90e7030b/read/' . urlencode('http://localhost:8000/profile');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.