1

I'm trying to remove the public/index from laravel url, since this is one of the common question so there are lot of tutorials and answer. I also searched about this and followed this answer which is working fine for me it's pretty simple.

Rename the server.php in the your Laravel root folder to index.php and copy the .htaccess file from /public directory to your Laravel root folder. -- Thats it !! :)

I'm confuse why i should rename or move something from one place to another because there will be a reason why files exist in public folder.

I'm thinking that by following above answer's step may be create some issues in future if there will be a new requirement or new feature request in the project.

So can anyone guide me is there any best to rewrite or remove the public/index from laravel 5. I would like to appreciate if someone guide me.

miken32
  • 42,008
  • 16
  • 111
  • 154
Ayaz Ali Shah
  • 3,453
  • 9
  • 36
  • 68
  • can you check these steps once - http://stackoverflow.com/questions/16884947/laravel-installation/18908991#18908991 note sure whether it would help you but just wanted to share with you if you can look at it once. – Mittul Chauhan Aug 24 '16 at 09:55

4 Answers4

5

You should configure your web server's document / web root to be the public directory. That way you don't have to copy/move/delete anything.

For apache you can look here.

For nginx you can read here.

Community
  • 1
  • 1
Can Vural
  • 2,222
  • 1
  • 28
  • 43
1

I've visited your link and saw really terrible advices.

You do no need to move any Laravel files or modify them. What you need is to setup web server. You need to point it to a public directory which is inside Laravel project root folder.

Please look here for an example config directives for Apache and nginx.

Community
  • 1
  • 1
Alexey Mezenin
  • 158,981
  • 26
  • 290
  • 279
-1

One other option is to symlink the public folder to your server's root folder (e.g. /var/www/). This article is a great guide on how to do this.

On your dev environment however you can use php artisan serve.

Alfonz
  • 1,010
  • 13
  • 26
-1

Remove public from url without htaccess. It will work on laravel latest versions also.

step 1. Copy all files from public and paste on root directory

step 2. Open index.php file remove ../ from path as given below

Laravel5:

require __DIR__.'/../bootstrap/autoload.php';

to

require __DIR__.'/bootstrap/autoload.php';

and

require_once __DIR__.'/../bootstrap/app.php';

to

$app = require_once __DIR__.'/bootstrap/app.php';

Laravel 7:

require __DIR__.'/vendor/autoload.php';
$app = require_once __DIR__.'/bootstrap/app.php';
Kabir Hossain
  • 2,865
  • 1
  • 28
  • 34