Reputation: 15734
I am using Laravel 5. In a specific Blade template, I have a link that looks like this:
<a href="/categories/1">{{ $category->category }}</a>
Normally on my localhost WAMP server, I can access my main page that has this link, like this:
http://localhost:8080/myApp/laravel/public/
When you click the <a>
link above, I want the link to simply go to:
http://localhost:8080/myApp/laravel/public/categories/1
Instead, it goes here:
http://localhost:8080/categories/1
If I don't include the leading "/" on categories/1
. then it simply keeps adding categories/1
to the url everytime I click it. The first time it works, but the second time (and on) it of course says page not found.
What is the appropriate way to handle routing links in Laravel using the Blade templates?
Upvotes: 0
Views: 3535
Reputation: 3551
Try this
<a href="{{ url('categories/1') }} ">{{ $category->category }}</a>
Upvotes: 1