user2342308
user2342308

Reputation: 1

How to solve route in Laravel 5 not working

I'm new php developer and interest use laravel framework5

when I access link localhost/project/public/

It's work

and i add function in route

> Route::get('home', function () {
>     return View::make('home.home'); });
> 
> Route::get('contact', function () {
>     return View::make('contact.contact'); });

i access link localhost/project/public/home or localhost/project/public/contact

it's show error 404 page not found

but i can access by localhost/project/public/index.php/home but it's no have js file and css file

in my htacess file

Options -MultiViews

RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]

# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

RewriteRule ^(.*)$ public/$1 [L] </IfModule>

i use xampp and enable mod_rewrite already

what wrong i missing to settings ?

Thank you

Upvotes: 0

Views: 3114

Answers (4)

Karthik SWOT
Karthik SWOT

Reputation: 1217

Clear the previous cached routes once and then try

php artisan route:clear

Upvotes: 0

Masoud Haghbin
Masoud Haghbin

Reputation: 883

why don't you use the command

php artisan serve

in your project root where the artisan file available and then you can access your project by using http://localhost:8000

Upvotes: -1

Ash
Ash

Reputation: 3399

I would say your Virtual Host is not configured correctly. Since I cann't see exactly how this is done my assumption is your Virtual host is not setting public as Document root:

Try something like the following.

<Directory /var/www/vhosts/YOURHOST/public>
    AllowOverride None
    Options -Indexes +FollowSymLinks

    RewriteEngine On
    RewriteBase /

    RewriteRule ^(.*)/$ /$1 [L,R=301]

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</Directory>

Notes

RewriteRule ^(.*)$ public/$1 [L] < /IfModule>

So essentially this will never run because of the previous RewriteRule is being executed and stopped due to RewriteRule ^ index.php [L]

Upvotes: 0

Borja Marco
Borja Marco

Reputation: 54

Try to see your routes with the following command:

php artisan route:list 

And see what you get.

Execute this after:

composer dump-autoload

try again.

Upvotes: 2

Related Questions