3

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:

patricus
  • 59,488
  • 15
  • 143
  • 145
Al bassam
  • 225
  • 1
  • 4
  • 16

1 Answers1

6

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.

patricus
  • 59,488
  • 15
  • 143
  • 145