I have created a new laravel project as i always do and for some reason the default welcome page isnt loading and shows the error message Sorry, the page you are looking for could not be found.
I have searched for other answers which all give examples of what to put into your .htaccess file but mine already has the code examples i have seen inside it. Thank you in advance
Web.php
Route::get('/', function () {
return view('welcome');
});
The welcome.blade.php has the default code for the laravel welcome page
My htaccess file
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
Related
My laravel project is throwing error on sub-domain of hosting. My code is working fine on other hosting's sub-domain. However, on this here is shows error as show in image below.enter image description here.
My .htaccess file
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
Please help me out to solve this issue. Thanks in advance :)
I have a project with Laravel and inside the public folder (httpdocs) I have a folder /en/news, all works fine with the route /en/news but when I try to go to the /en I have a 403 error because it is a empty folder, the real problem there is that /en is a route in my Laravel project with the homepage of the web, so first executes de .htaccess and throw the 403.
Is there any way to ignore this error for this specific folder/route (/en) or something like that?
My .htaccess is the tipical Laravel .htaccess
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
The solution:
Add before the # Send Requests To Front Controller... the next rewrite:
RewriteRule ^en/$ index.php [L]
This send the request to the index.php ignoring the checks for this specific route.
I have a Laravel 7 project and I'm using XAMPP for my localhost. The project folder is in C:\xampp\htdocs\eegore-new. I've copied my .htaccess file from the public folder (the other one still exist in public directory), and put it in to the root directory and changed the server.php into index.php so I can now access my my application via localhost with this url -> http:://localhost/eegore-new. But once I clicked my login button on that page, it redirected me to http:://localhost/login which shows 'Object Not Found, Error 404' while it should redirected me to http:://localhost/eegore-new/login so the page can load correctly.
I've changed my APP_URL in .env file to <'http:://localhost/eegore-new-copy'> and tried to change my .htaccess file in my root folder.
This is my folder structure :
My folder structure screenshot
This is the .htaccess in my root folder, I tried RewriteBase but its not working:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
RewriteBase /eegore-new/
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
And this is the .htacess in my public folder:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
I have to make all the routes functioning just like http::/localhost/eegore-new/login or /user or /other but I'm not really sure what to do or where to start actually and I know nothing about .htaccess.
Any help will be really appreciated, thanks in advance!
I m noob at php based web development, I'm trying a Laravel from scratch tutorial.
First I had an issue with the .dev that I fixed in laragon preferences using a .mc that will not forces https.
My link is http://localhost/e-commerce-tutorial/public/ for the welcome page
Now I m trying to create a routing scenario
I did put an about.blade.php page in : resources/views/pages
Then I edited the laravel wellcome page adding this link to the menu :
About
finally my web.php
Route::get('/', function () {
return view('welcome');
});
Route::any(
'/about',
function (){
return view('pages.about');
}
);
I did some research but no success:
I tried this two .htaccess
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
OR
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
My browser response is :
Not Found The requested URL /e-commerce-tutorial/public/about was not
found on this server.
Try this
.htaccess file
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
#RewriteBase /~projectname/master/
# 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]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
Also Please try this
Route::get('/about', function () {
return view('pages.about');
});
Route::post('/about', function () {
return view('pages.about');
});
I have install a fresh copy of laravel 4.2
When i visite home route (localhost/public/) it work fine but when i visit other route as like "localhost/public/kk" it show NotFoundHttpException.
here is my route.php file
<?php
Route::get('/',function(){
return View::make('hello');
});
Route::get('/kk',function(){
return View::make('hello');
});
here is .htaccess file
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
The entry point for all requests to a Laravel application is the public/index.php, therefore it would be available here --> localhost/public/index.php/kk
for further info you can go to this link.
First check if you have enabled the mod_rewrite module.
Then.. according to the documentation you should try an alternative .htaccess if the .htaccess that ships with Laravel does not work.
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
Edit: Enable mod_rewrite in xampp