I installed Laravel latest version i.e v7 but when I try to change the route or create my own route that route is not working.
Here is the default route.
Route::get('/', function () {
return view('welcome');
});
This is what I’m trying to hit URL in the browser:
http://localhost/mobileshop/public/
This is working fine but when I try to change it or write my own route it shows error 404 | not found
This is what I’m trying when I get this error
Route::get('/login', function () {
return view('welcome');
});
Or
Route::get('/login', function () {
dd("my own route");
});
Both are not working what to do?
This is what I’m trying to hit URL in the browser:
http://localhost/mobileshop/public/login
I researched and found something here: https://laracasts.com/discuss/channels/laravel/order-of-routes-in-webphp?page=1
but whatever they tell I don’t think I’m doing that mistake, am I?
I’m using XAMPP.
I myself changed route, views, and many other things but still, I’m there at error 404.
When I stop XAMPP and run php artisan serve and use: http://127.0.0.1:8000/login URL in browser its working fine. So is there any issue in my XAMPP? If there is an issue in my XAMPP then why default route is working I’m not understanding.
Can anyone help me to issue and about how to use XAMPP rather than php artisan serve?
Thanks in advance.
2
Answers
php artisan serve
in cmdAfter Then you try 127.0.0.1:8000/login in browser
This is very likely because how you run your laravel, An easy way is that you may need to run this command at your root of your laravel and in the terminal you will get a
url
just use that and you should be fine.Working with xampp:
C:WindowsSystem32driversetchosts
and add a new line like:127.0.0.1 yoursite.local
xamppapacheconfextrahttpd-vhosts.conf
Then add a virtual host in the bottom of the file like:Then you can access your route by typing:
yoursite.local/login
oryoursite.local:80/login