symfony / recipes-contrib

Symfony Contrib Recipes Repositories

Home Page:https://github.com/symfony/recipes-contrib/blob/flex/main/RECIPES.md

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[apache-pack] serving existing files

prohde opened this issue · comments

When I was using the .htaccess file from the apache-pack recipe my existing files in the "public" directory where not served by Apache 2.4.

I had to change the line RewriteCond %{REQUEST_FILENAME} -f to RewriteCond %{REQUEST_FILENAME} !-f in order to get my files served.

Is this a bug in the recipe or just strange behavior on my Apache server?
If it is a bug I would be happy to create the PR for it.

Any information on this?
[I am on symfony 4.6]

Original condition and rule:
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
What I understand: If an existing file is requested, do not change the URL and serve the file.
What I observe: The files are not served.

Changed condition and rule:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ - [L]
What I understand: Serve the requested URL if it is not an existing file.
What I observe: The existing files are served.

Hey.
Thank you for this issue. To clarify a little bit:

RewriteCond %{REQUEST_FILENAME} -f - If you requesting an existing file, ie a file that matches the URI
RewriteRule ^ - [L] - Do no rewrites and this is the last rule to parse.

With your suggested change you would disable "friendly urls".

Im not sure why you observed the effects the other way around. I suspect browser cache and maybe your webserver cache the .htaccess file for a short time for performance reasons.