why show NotFoundHttpException - php

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

Related

Laravel 9 - 404 error on welcome.blade.php file

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>

Rewriting URL from htaccess is doing wrong

I have a Laravel project and I have defined routes like:
Route::get('/', 'WebController#index');
Route::get('/user/signin', 'WebUserController#userLogin');
Route::get('/user/signup', 'WebUserController#userRegister');
Route::post('/user/save', 'WebUserController#userSave');
And the absolute routes of my project are:
localhost/project/ (it's working ok)
localhost/project/user/signin wasn't working ok.
Then, I added a .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]
</IfModule>
And the routes for signin and signup are working good, except when I'm trying to use user/save from signin is redirecting to:
localhot/user/save
What is wrong with my .htaccess fie?

Laravel on Plesk Routing Issue

I can't access my routes when I uploaded my site on Plesk. I get 404 error
I am using Laravel Version 4.2
I made the default directory to httpdocs/public/
Here's my .htaccess file in public folder.
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
RewriteBase /
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
Please help.

How to remove public/index.php from url in laravel 5?

I am using laravel 5 and having one problem when i upload my project on rackspace it is showing public/index.php in the url. Without this my project is not working.
Please help me .
Htacesss of my public is this :-
<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>
With regards
Harpartapsingh
You do this by making the /path/to/laravel/public folder itself your webroot in Apache/nginx instead of /path/to/laravel. With that, and the standard .htaccess in the public folder, you should be able to access your routes without the public or index.php URL segments.
copy your .htaccess file from your public folder and paste in your root directory
with this code inside .htaccess:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# 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]

Routes not working without index.php in laravel 4.2

I have spent a considerable amount of time googling for suggestions for this, and despite setting up several test project in Laravel 4.2 before on xampp server.
I am not sure what I am missing in this project...
I have one more project on server and it is working fine But when I tried to start this new project I started getting this error.
XAMPP version 5.6.3
PHP version 5.6.3
This is my .htaccess file :
RewriteEngine on
Options -MultiViews
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]
This is my Routes.php file :
Route::get('/admin', function(){
echo 'hello';
});
My url is :
http://localhost/adminpanel/public/admin
And showing this error :
Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException
When I write this url : http://localhost/adminpanel/public/index.php/admin Now works fine..
Try this htaccess on your public folder
<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]

Categories