0
votes
I am Working on Localhost (WAMP server, php version 5.5.12)

url: http://localhost/laravel/

my root directory .htaccess is:

   <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^(.*)$ public/$1 [L]

Public Directory .htaccess is :

<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]

In this scenario when I want to access: http://localhost/laravel/ following error message appears: Sorry, the page you are looking for could not be found.

1/1 NotFoundHttpException in RouteCollection.php line 161:

But when I access : http://localhost/laravel/public/ It successfully loads home page. I have debugged every thing in url rewriting it works fine but laravel not accepting new urls. Can anyone please help me regarding this issue.

1
what type of web server are you using? wamp or php artisan serve or homestead?Emeka Mbah
I am using WAMP serverRafaqat
Why not use php artisan serve it will save you the stressEmeka Mbah
move index.php and .htaccess file from /public folder to the root. you can get perfect answer from https://stackguides.com/questions/28364496/laravel-5-remove-public-from-url/32519877#32519877Miron

1 Answers

0
votes

You can simply solve this problem. From your public directory index.php file move in root directory like "project-name/index.php" Then edit your index.php file In line 22 replace "require DIR.'/../bootstrap/autoload.php';" this with "require DIR.'/bootstrap/autoload.php';"

and line no 36 replace "$app = require_once DIR.'/../bootstrap/app.php';" with "$app = require_once DIR.'/bootstrap/app.php';"

Now edit autoload.php from "project-name/bootstrap/autoload.php" here replace line no 17 "require DIR.'/vendor/autoload.php';" with require DIR.'/../vendor/autoload.php';

now browse your project-name. I think it will solve your problem. You can also laravel development server as localhost:8000 for this open your project folder in command window and type "php artisan serve" hit Enter.