-
-
Save Guibzs/a3e0b3ea4eb00c246cda66994defd8a4 to your computer and use it in GitHub Desktop.
<IfModule mod_rewrite.c> | |
Options -MultiViews | |
RewriteEngine On | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteRule ^(.*)$ index.php [QSA,L] | |
</IfModule> | |
<IfModule !mod_rewrite.c> | |
<IfModule mod_alias.c> | |
RedirectMatch 302 ^/$ /index.php/ | |
</IfModule> | |
</IfModule> |
Hi @drondar, as you said, assuming that you are running an application with a front controller (index.php) in a folder '/public', all files which are intended to be 'public' (normally the front controller and all the assets: js, css and images) should live inside this folder.
So, since they are public, there's no reason to have restrictions on it.If you want to protect the directory which contains the project (or business logic) like for example /src, you can put an .htaccess with a redirect to parent folder on each subfolder.
Here an example:
RewriteEngine On RewriteRule ^(parent/). /$1 [R,L]
where 'parent' is the name of the parent folder.
You can replace R param with R=301 if you want to make it 'permanent' (but only when you are sure that it works).Another option is working with folders' permissions if you are on Unix.
Hello, my situation is exactly what you are describing. Thank you very much, I'm going to try it right now.
Worked on Symfony 4
Hi @drondar, as you said, assuming that you are running an application with a front controller (index.php) in a folder '/public', all files which are intended to be 'public' (normally the front controller and all the assets: js, css and images) should live inside this folder.
So, since they are public, there's no reason to have restrictions on it.
If you want to protect the directory which contains the project (or business logic) like for example /src, you can put an .htaccess with a redirect to parent folder on each subfolder.
Here an example:
where 'parent' is the name of the parent folder.
You can replace R param with R=301 if you want to make it 'permanent' (but only when you are sure that it works).
Another option is working with folders' permissions if you are on Unix.