Reputation: 1337
I have a laravel project served by apache and located in the apache root folder and accessed at http://hostname/foo and I have troubles to map an url to a controller method. The following is the controller with the method (simplified for the purpose of illustration).
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
class ShowController extends Controller
{
public function show($id)
{
return 'show: ' . $id;
}
}
The following is the route mapping in routes/web.php
Route::get('show/{id}', 'ShowController@show');
The trouble is that the url like the following doesn't work.
http://hostname/foo/show/1
The above url got me to phpinfo(). But the following url gave the expected result.
http://hostname/foo/public/show/1
The following mappings don't work either.
Route::get('/show/{id}', 'ShowController@show'); // with a leading slash
Route::get('show/{id}', 'ShowController@show')->name('show');
Route::get('/show/{id}', 'ShowController@show')->name('show'); // with a leading slash
I appreciate any info or suggestion. Thanks. My php is 7.1.
Upvotes: 1
Views: 363
Reputation: 2390
This entry point of Laravel will always be /public
.
You can find how configure Apache here :
How to configure apache web server to deploy laravel 5
Upvotes: 1
Reputation: 101
I believe you use something like xamp, wamp... I recommend not using theses but launch the server with php artisan serve
. This way, you could access your website on localhost:8000 by default.
Upvotes: 0