Reputation: 1073
I set project path in /config/app.php
like as:
http://localhost/project/public/
So, when I call any controller clicking by link:
<a href="/users">Users</a>
This calls controller users
.
As you see href
is absolute.
How I can set link for each links with full path project, like as:
http://localhost/project/public/users
Upvotes: 0
Views: 2339
Reputation: 4205
The best practice is to use named routes, with that routes will work dynamically unlike url('path')
where you have to change path manually everywhere.
Route::get('user/profile', [
'as' => 'profile', 'uses' => 'UserController@showProfile'
]);
You can access full path with this helper method
route('profile')
This also works works for dynamic routes like
Route::get('profile/{id}', [
'as' => 'profile', 'uses' => 'UserController@showProfile'
]);
Pass $id
or any array as second parameter.
route('profile', $id)
https://laravel.com/docs/5.2/routing#named-routes
Upvotes: 1
Reputation: 180176
Use Laravel's helpers for this.
https://laravel.com/docs/5.2/helpers
The url
, route
, and action
helpers all do this (in slightly different ways).
<a href="{{ url('users') }}">Users</a>
Side-note: Your non-public folders should never be exposed to the public internet in production. Your webserver should be pointed to the public
folder as its document root.
Upvotes: 3