0
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.

Rafaqat
  • 81
  • 7
  • what type of web server are you using? wamp or php artisan serve or homestead? – Emeka Mbah Oct 12 '15 at 08:46
  • I am using WAMP server – Rafaqat Oct 12 '15 at 10:04
  • Why not use `php artisan serve` it will save you the stress – Emeka Mbah Oct 12 '15 at 13:17
  • move `index.php` and `.htaccess` file from `/public` folder to the root. you can get perfect answer from [http://stackoverflow.com/questions/28364496/laravel-5-remove-public-from-url/32519877#32519877](http://stackoverflow.com/questions/28364496/laravel-5-remove-public-from-url/32519877#32519877) – Miron Dec 16 '15 at 14:09

1 Answers1

0

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.

Jakarea Parvez
  • 540
  • 6
  • 9
  • I have seen many posts which describe removing "public" from url using following htaccess: RewriteEngine On RewriteRule ^(.*)$ public/$1 [L] But I could not understanding How can that work in this scenario? Can you plz describe it? – Rafaqat Oct 12 '15 at 10:18