The get in laravel doesn't find any page - php

I am very a beginner in Laravel
I launch my laravel project on localhost
<http://localhost/ecommerce/public/>
Route::get('/', function () {
return view('welcome');
});
this give me the welcome page
But I want to add about page but it always say "404 Not found"
and that's my code:
Route::get('/about', function () {
return view('about');
});
I made a file in views and called it "about.blade.php"
when I type to view about like this :
Route::get('/', function () {
return view('about');
});
and remove the welcome get, it works and give the about page
but when I put it in get "/about" it always doesn't work, even if I just type "string"
why it can't recognize get "/about"?

You should run the project with php artisan serve in terminal or in the server you have to change document root and remove the public in URL
the reason is the extra public in your url

Related

How to change the default landing page after serve command

I am wondering if it is possible to change the default startup address after the command
php artisan serve
Because when I run it, I get the default url
Starting Laravel development server: http://127.0.0.1:8000
But my "first page" is when I type
http://127.0.0.1:8000/index
in the browser.
So is it possible to automatically give out http://127.0.0.1:8000/index after startup?
If you want to show your index.blade.php at first place then just replace in your routes/web.php
From this
Route::get('/', function () {
return view('welcome');
});
TO this
Route::get('/', function () {
return view('index');
});

PHP Laravel route after installation

I installed new laravel project("Starter") and want to view the 'welcome' page by putting this URL.
http://localhost/starter/
The page ran fine when the route is the following.
Route::get('/', function () {
return view('welcome');
});
However, when I write any thing after the (/)...
Route::get('/test', function () {
return view('welcome');
});
And view it by URL:
http://localhost/starter/test
The page doesn't work and shows...
404
Not Found
Any ideas?
(s) in word (starter) in the URL, shoud be UpperCase (Starter) as the name of Laravel project

Change the route in Aimeos Laravel

I am using Aimeos e-commerce on a Laravel site, I want to change the store route to /shop but I get an the browser doesn't open a page I do it as follows
Route::get('/shop', function () {
return redirect('shop');
})->name('shop');
but when I make on "/" main page it displays perfectly. How to change its route?
Use this in your route/web.php file:
Route::get('/', function () {
return redirect('shop');
});
See https://github.com/aimeos/aimeos/blob/master/routes/web.php

Redirecting to external url, resulting in 404 laravel 5.8

I thought this would be fairly simple, but I'm stumped.
I have a link on my site nav that goes to an aws pdf file and works fine. I'm trying to create a named route that a user could type in and also redirect to that file but I'm getting a 404.
I've tried:
Route::get('Documents', function () {
return redirect()->away('http://s3.aws/documents.pdf');
});
Route::get('Documents', function () {
return redirect()->to('http://s3.aws/documents.pdf');
});
Route::get('Documents', function () {
return redirect('http://s3.aws/documents.pdf');
});
And they all result in 404 when I visit www.mysite.com/Documents
Any ideas?
Just use
return Redirect::to($url);
Read more about laravel redirects here.

Redirect All URL's With A Particular Pathname To A Certain View - LARAVEL

Okay i'm running two react projects using laravel, a website and an admin section. I want both apps rendered on separate pages because their css would clash.
So in my web.php i have this Route::view('/{path?}', 'app');, but this redirects all my routes to my app.blade.php view.
I'm justing wondering if i can have a route that redirects any route with a specific pathname, let's say: mydomainname.com/admin to my admin.blade.php. Then every other route goes to my app.blade.php.
You can use Route::prefix like this:
Route::prefix('admin')->group(function () {
Route::get('users', function () {
// Matches The "/admin/users" URL
});
});
Okay i was able to pull it off. Erkan Ozkok's answer gave me a hint.
Route::prefix('admin')->group(function () {
Route::view('/{path?}', 'admin');
});
Route::any('{query}',
function() { return view('app'); })
->where('query', '.*');

Categories