I recently moved my index.php
(the file that handles routing) and css/js/font assets to a public/
folder. I only want items in this public/
folder to be accessible for security purposes. I ran into this problem when I realized I could visit mysite.com/composer.lock
and view the composer lock file with my old .htaccess
and folder setup.
Here is what I want
If I visit mysite.com/car/create
, I want it to actually point to mysite.com/public/index.php?path=car/create
If I link to an asset such as mysite.com/css/style.css
, I want it to really point to mysite.com/public/css/style.css
Here is my folder structure
Here is my .htaccess
which is not working at all
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ public/index.php?path=$1 [L,QSA]
</IfModule>
I'm not sure how to fix this. It just generates empty pages and I can still directly visit files in the root directory etc. Any help is appreciated.