4

I am pointing everything into /public folder with this .htaccess.

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

It is fine, i can load /administration path without /public, but the problem is, that i can also load it like this /public/administration.

Tadeáš Jílek
  • 2,813
  • 2
  • 19
  • 32
  • I have previously answered a very similar question at http://stackoverflow.com/questions/22075238/uploading-laravel-project-onto-web-server/22075459#22075459, albeit for Laravel 4 so I don't know if it is still applicable to Laravel 4, but I imagine it is. – alexrussell May 11 '15 at 15:56
  • I also had same problem with Laravel 5. This solution worked for me. http://justcode.me/laravel/remove-public-index-php-url-generated-laravel/ – Luzan Baral Aug 11 '17 at 13:48

2 Answers2

2

Try this alternative .htaccess file:

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

Source: Laravel Documentation's §Installation > #Pretty Urls

Томица Кораћ
  • 2,542
  • 7
  • 35
  • 57
1

If I understand correctly, it looks like your virtual host config is pointing to the directory above public. Why? Do you need it to be this way for some reason?

Laravel should work out of the box with Apache provided your document root is set to the public dir. That's why there's a default .htaccess inside that directory.

Riari
  • 58
  • 2
  • 5
  • Thanks for information, but this is not an answer to my question. – Tadeáš Jílek May 11 '15 at 09:23
  • Why isn't it? What's stopping you from changing your document root? – Riari May 11 '15 at 09:35
  • On my localhost i can do it, but on hosting i have got access just only for web. I am trying to achieve this on hosting, on localhost i use artisan serve. – Tadeáš Jílek May 11 '15 at 09:38
  • OK, that makes sense. I assume none of the answers here help you: http://stackoverflow.com/questions/28364496/laravel-5-remove-public-from-url – Riari May 11 '15 at 09:39
  • Changing the structure is not recommended, but i have tried it. And i also tried to point with .htaccess. – Tadeáš Jílek May 11 '15 at 09:47
  • What did you end up doing? Did this work or not. I see you accepted the answer, but in the comments you explain that it doesn't work. – davejal May 23 '16 at 23:29