I'm new with Symfony and I'm working on a test project to improve my knowledge. Actually I'm learning Routing and what I'm trying to do is to deny access if a file with .disabled
extension is requested. I'm talking about files placed in web
directory. So, for example, file located at web/config.php.disabled
cannot be executed/downloaded.
Then I created a route like this
/**
* @Route("{req}disabled", name="denyAccess", requirements={"req"=".+"})
*/
public function denyAccessAction(Request $request, $req)
{
return new Response('Access denied');
}
and is working fine when I request a file that doesn't exist (e.g. http://my.website/file.php.disabled). But when I request an existing file, the route doesn't work and I can download that file without problems. So I guess requesting an existing file placed in web directory will override any route.
How can I make my route have higher priority than a requested file in web directory?