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
Related
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
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
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.
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', '.*');
Let's say I am defining the following route in Laravel 5.3:
Route::resource('bands', 'BandController');
The default route example coming when you start a new Laravel project has the following:
Route::get('/', function () {
return view('welcome');
});
How do I make bands route to be the default one when no controller is called instead of welcome? Meaning /?
I did read docs here but didn't found anything. Any?
Place that block inside laravel/app/routes.php instead of a Controller (4.x)
Place that block inside laravel/app/Http/routes.php instead of a Controller (5.1)
Place that block inside laravel/app/routes/web.php instead of a Controller (5.3)
Route::get('/', function()
{
return view('welcome');
});
You can redirect default to anywhere you want, i.e.:
Route::get('/', function()
{
return Redirect::to( '/bands');
// OR: return Redirect::intended('/bands'); // if using authentication
});
As #Patrick mentioned, you can simply redirect to the /bands route. However, I have to warn you that the redirect will actually change the URL in the navigation pane of the web browser. I would have suggested that you just ask the home route to use the index method of your BandController as follows:
Route::get('/', ['uses'=>'BandController#index']);