0

This is my folder structure for Laravel 5.2

-laravel --app --bootstrap --config ... 

Under the laravel folder that is root of Laravel, I added an .htaccess file with following code:

RewriteEngine On RewriteRule ^(.*)$ public/$1 [L] 

Now when I open project in browser I get the error:

Sorry, the page you are looking for could not be found. "NotFoundHttpException in RouteCollection.php line 161:"

I am using XAMPP. Why I am getting this error? How can I remove public from the URL using this method?

0

5 Answers 5

1

You need to point your web server to a public directory instead of project root directory. Use original .htaccess and these Apache settings:

DocumentRoot "C:/xampp/htdocs/public" <Directory "C:/xampp/htdocs/public"> 

Restart Apache to make it work.

Sign up to request clarification or add additional context in comments.

Comments

0

The best way is to create a virtual host in xampp and set its DocumentRoot to laravel public folder. Here is a nice tutorial on how to create vhosts in xampp

https://delanomaloney.com/2013/07/10/how-to-set-up-virtual-hosts-using-xampp/

Comments

0

create a folder and name as you want, move all the files inside that folder except public, move the content of public folder to root. After you must edit index.php and change [newFolder] by your news folders name

require __DIR__.'/[newFolder]/bootstrap/autoload.php'; $app = require_once __DIR__.'/[newFolder]/bootstrap/app.php'; 

2 Comments

I followed this, but no success. Is there anything else which may be stopping this method. I have tested this in a another machine but its not working in my machine. I have tried it several times but no success. I am not able to understand whats happening.
with that method you can remove the public URI, so just get your .htaccess file as default and try what I said :) @Mukesh
0

•Go to mainproject/public>>

a. .htacess b. favicon.ico c. index.php d. robots.txt e. web.config 

1.cut these 5 files from public folder,and then paste on the main project folder that’s means out side of public folder… mainproject/files

2.Next after paste ,open index.php ,modify

•require __DIR__.'/…/bootstrap/autoload.php'; to •require __DIR__.'/bootstrap/autoload.php'; modify $app = require_once DIR.'/../bootstrap/app.php'; to $app = require_once DIR.'/bootstrap/app.php'; 

Comments

0

Change your httpd.conf file from

DocumentRoot "C:/xampp/htdocs" <Directory "C:/xampp/htdocs"> 

to

DocumentRoot "C:/xampp/htdocs/{projectname}/public" <Directory "C:/xampp/htdocs/{projectname}/public"> 

restart apache. then you can now access your project in url localhost/

1 Comment

use this in xammp

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.