Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 404 error with xampp

Tags:

laravel

I am starting to learn how to work with laravel but got a problem. When I go to: http://localhost/testing/public/ I get a working page but when I typ for example http://localhost/testing/public/home which is one of my views I get a 404 error. Does someone know how to fix this?

Edit: I am using the latest version of laravel and when I do for example:

Route::view('/home', 'home');

In my routes/web.php I get that error

like image 899
MrAndre Avatar asked Dec 07 '25 22:12

MrAndre


1 Answers

This is more likely a problem with virtual Hosts, try the following:

  • First edit your route to :Route::get('/home', function(){echo "hello"});
  • Then try to access: http://localhost/testing/public/index.php/home

If it works then its certainly because you don't have a virtualHost, you can set it easily in your Xampp config and modifying ur hosts file

  • First go to C:\Windows\System32\drivers\etc\hosts and add a new line like: 127.0.0.1 yoursite.local
  • Then go to where xampp is installed under xampp\apache\conf\extra\httpd-vhosts.conf
  • Then add a virtual host in the bottom of the file like:

<VirtualHost *:80>

DocumentRoot "PATH_to_laravel_folder/public"  

ServerName yoursite.local  

</VirtualHost>

  • Then you can access your route by typing: yoursite.local/home or yoursite.local:80/home

Hope it helps you guys :)

like image 87
Sletheren Avatar answered Dec 11 '25 12:12

Sletheren



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!