Reputation: 841
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?
Upvotes: 0
Views: 1126
Reputation: 1
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/
Upvotes: 0
Reputation: 548
•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';
Upvotes: 0
Reputation: 450
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';
Upvotes: 0
Reputation: 1290
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/
Upvotes: 0
Reputation: 163748
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.
Upvotes: 1