Reputation: 225
I have a search input for customers. The customers have an address, and some of the addresses contain the number sign, for example #51 Scout Fuentebella
. I included address in my search.
My route:
Route::get('customer/search/{input}', 'CustomerController@search');
Whenever I search for their address like localhost:8000/customer/search/#51 Sc, I get the following error:
NotFoundHttpException in RouteCollection.php line 161:
Upvotes: 3
Views: 3810
Reputation: 62338
The hash mark (#
) has special meaning inside of a url. It marks the start of the fragment identifier and is only handled on the client side. Nothing after the #
will be sent to the server.
If your url needs to have a hash inside of it, then you need to urlencode the data before building the url.
#
encodes to %23
, so for your example, localhost:8000/customer/search/%2351%20Sc
should work fine.
Upvotes: 6