0

I have developed one laravel application. Initially we have executing http://127.0.0.1/laravel_app/public this url structure.

Ater completing application i have moved to server with domain.

Example: http://www.example.com it working fine. I have integrated .htaccess to remove public. its working fine.

But i have try to http://www.example.com/public/index.php above url manually typed site will display.

How can remove if users enter manually enter this type of URL http://www.example.com/public/index.php

James Z
  • 12,209
  • 10
  • 24
  • 44
osizbala
  • 1
  • 2
  • have you put file `index.php` outside of public folder..? – Shailendra Gupta Oct 29 '18 at 12:40
  • Just to confirm, you're asking how to redirect users that hit a `http://yoururl/public/what/ever/after` to the same without the `/public`? – Jonnix Oct 29 '18 at 12:44
  • I think this will work, add this to your `.htaccess` file ` RewriteRule ^(.*)$ public/$1 [L]` – Shailendra Gupta Oct 29 '18 at 12:52
  • Why don't you just disallow access to the `public` folder from the `.htaccess` file? – nomorehere Oct 29 '18 at 13:07
  • You can check https://stackoverflow.com/questions/28364496/laravel-5-remove-public-from-url this – Shamsur Rahman Oct 29 '18 at 13:12
  • You can select the root folder for your domain in the domain editor of your webspace. There you just tell the domain that it's root folder is `/laravel_app/public` and every request to your domain is going to be forwoarded to this folder. You can also do this on your local maschine, either laravel homestead or xampp or whatever you link. – Patrick Schocke Oct 29 '18 at 13:22
  • Laravel's `public` folder should be your domain's root. This involves some webserver configuration, but is important for making sure the non-public files are inaccessible to browsers. – ceejayoz Oct 29 '18 at 14:55

2 Answers2

0

You should use below code in your .htaccess file.

<IfModule mod_rewrite.c>
   RewriteEngine On 
   RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
  • You should not. Putting your non-public files in a web-accessible spot is not a good idea - it is a potential security vulnerability. – ceejayoz Oct 29 '18 at 14:54
0

use this

RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
Shailendra Gupta
  • 1,054
  • 6
  • 15