Reputation: 406
I'm reasonably new to Laravel, I've worked with Laravel 4 but decided to use the fancy new Laravel 5 for a personal project and to really learn it.
I thought of posting this over at Webmasters.SE but couldn't find any other questions regarding Laravel.
I couldn't find any solutions on the internet and I'll gladly provide more information.
So I just installed a fresh Laravel 5 application using their own installaton how-to on my WAMP server locally. I did the whole Composer mumbo-jumbo, everything did it's job and no errors were shown.
Problem
Now here's my problem, when I access the site using http://localhost/test.com/public/
I get the default page, just as it is supposed to be.
In the routes.php
(shown below) you'll see that they defined a home
route. So I typed it in my url bar as so http://localhost/test.com/public/home
and I get redirected back to http://localhost/test.com/public/auth/login
, as shown in the following image.
(It has no styling whatsoever, I'm asuming it is supposed to be like this?)
Anyway, I get there, and I hover over Home
and the tiny url bar in the bottom left/right shows just http://localhost
and clicking on it redirected me to the WAMP Server main page.
These are URLs they link to:
http://localhost
http://localhost/auth/login
http://localhost/auth/register
http://localhost/password/email
The required result is supposed to be that I should be redirected to http://localhost/test.com/..
I have no idea where this could've been caused, I'm asuming this is something that has to with .htaccess
, routes.php
or paths
not being set correctly. I have tried modifying both .htaccess
and routes.php
but I clearly lack the knowledge to debug this problem by myself.
Code resources (fresh install, nothing has been changed)
routes.php
<?php
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Route::get('/', 'WelcomeController@index');
Route::get('home', 'HomeController@index');
Route::controllers([
'auth' => 'Auth\AuthController',
'password' => 'Auth\PasswordController',
]);
.htaccess
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
Upvotes: 0
Views: 7591
Reputation: 3828
You need to configure the url
parameter in config/app.php
(or your appropriate environment config file). By default, this is set to http://localhost
, so in your case you need to set it to http://localhost/test.com/public/
.
Edit
It looks like the urls in the views are hard coded (for example). The fix is the same as this answer, which is to replace every hard coded url (eg <li><a href="/">Home</a></li>
) with the url()
helper (eg <li><a href="{{ url('/') }}">Home</a></li>
).
Upvotes: 6