Create folder in symfony root that is not controlled by symfony
-
26-10-2019 - |
سؤال
I want to create http://localhost/Symfony/temp/
.
In temp will be a basic index.html and some images. If I create the folder right now and put the index.html file in /temp/ I get a 404.
How do I get a normal response from http://localhost/Symfony/temp/index.html
?
المحلول
Requests going to temp/
are being caught by Symfony's default .htaccess
. You'll have to add following:
# allow access to temp
RewriteRule ^temp.* - [QSA,L]
If you want it to work even with app_dev.php
just change it to ^[app_dev.php/]*temp.*
.
But I'm more interested why do you want to do that in root directory and not in static files directory (eg. web/static/temp). You wouldn't need to mess around with .htaccess
and you'd be able to link to such images with asset(...)
.
نصائح أخرى
Here's the solution I eventually came up with.
All I did was create a .htaccess file in /temp/ and inserted:
allow from all
Since I was getting a 404 error and all the other symfony folders had a .htaccess with
deny from all
I reversed engineered an answer.
Hope this helps someone else.