Raphael Rafatpanah
Raphael Rafatpanah

Reputation: 19997

Using pound sign (#) in Laravel routing?

Laravel has no problem routing the following URI:

$router->get('demo/toggle.html', function() {
  return View::make('ng.demo.toggle');
});

However, this one won't work for some reason.

$router->get('demo#/toggle.html', function() {
  return View::make('ng.demo.toggle');
});

Is there a way to make this work?

Upvotes: 1

Views: 541

Answers (1)

baao
baao

Reputation: 73251

Everything behind the hashtag (#) isn't send to the server, so Laravel can't catch it when you enter it in the browser. This is where the error comes from, Laravel only gets demo. You can try this with an existing, working route. Just write

demo/toggle.html#some_gibberish   <<< will still take you to demo/toggle.html

I'm wondering why you are using '..../toggle.html' as getter, one of the benefits of (Laravel's) url rewriting is that this is avoidable. You could use only toggle instead.

Upvotes: 2

Related Questions