I would like to serve my Laravel application on my local apache web server. However, I am having issues.
To test if the application I made would work on an apache server, I have created a new very simple application which contains two routes.
Route::group(['middleware' => 'web'], function() {
Route::get('/', function() { return view('myview'); });
Route::get('/link', function() { return view('myotherview'); });
});
When I enter my public
directory from my browser, it works fine, it connects to the /
route. But when I give a link to the other route (/link
), and try enter that route, it gives me 404 not found the error. Here is the link I give in my myview
view to reaching /link
route:
<a href="{{ url('/link') }}">Go</a>
When I show the source of the page, the above line is rendered as localhost/mylaravelapp/public/link
.
I have researched this issue on the internet and there are a couple of suggestions on enabling apache mod_rewrite. I have also done that by typing a2enmod mod_rewrite
. However this isn't seemed to be working, getting the same result. How can I solve this issue?
My laravel version is 5.2, apache 2.4.7 and I am using xubuntu 14.04.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…