1

The apache root Document is ~/Sites/ .

My laravel project is called laravelTest in the ~/Sites/laravelTest

The index url is http://localhost/laravel/public/index.php

And restful url is http://localhost/laravel/public/index.php/$1/$2 ...

How can I remove the /public/index.php?

How do I setting the .htaccess file...

I only can remove the index.php ,but can't remove the /public/

Thanks.

morewater
  • 67
  • 8

1 Answers1

2

There are many solutions for removing the index.php in Laravel 4,5 to remove public/index.php from URL

I would recommend you this simple step

  1. Rename the file server.php in the your Laravel root folder to index.php

  2. Move the .htaccess file from /public directory to your Laravel root folder.

Ref : As simple like this

Sulthan Allaudeen
  • 11,330
  • 12
  • 48
  • 63
  • yeah , its work for me... But can't only use .htaccess file to control this? – morewater Aug 06 '15 at 07:07
  • We can do it but there are some severe cautions because of it. That's the reason i suggest this :) – Sulthan Allaudeen Aug 06 '15 at 07:22
  • And I also has question. Now I can view my index in http://localhost/laravelTest/ but I thought http://localhost/laravelTest/public/ the resource(ex: img ) is 404 But i use laravel's Illuminate\Html provider for js ,css is work find. How can I use this for my img? – morewater Aug 06 '15 at 08:09
  • Sorry for late reply. Have you found the way ? or shall i help you ? – Sulthan Allaudeen Aug 06 '15 at 09:09
  • No, I hav't foud the solution. Can yout help me? Then I got another peoblem. lol I do something in my controller then I want redirect to another website ,but the page nothing happend... I use return redirect()->away('https://www.google.com'); Redirect::away('https://www.google.com'); Redirect::refresh('https://www.google.com'); Redirect::to('https://www.google.com'); but it doesn't work and no error. – morewater Aug 06 '15 at 10:49
  • this is my import. use Illuminate\Support\Facades\Redirect; use Illuminate\Http\RedirectResponse; Oh,I got error when I use Redirect::refresh got error InvalidArgumentException in Response.php line 470: The HTTP status code "0" is not valid. – morewater Aug 06 '15 at 10:52
  • Can you give the full url like `return redirect()->away('https://www.google.com');` – Sulthan Allaudeen Aug 06 '15 at 11:10
  • yeah ~ I'ved tried but it's the same. The page not refresh and not redirect... – morewater Aug 07 '15 at 01:05