Currently, I have a Symfony2.4 application that also links to a directory on our server (called "directories") located in the "Internet" folder. Files in this folder are automatically generated using an external program into simple html files by another department of our company.
Initially, we had these files open to the public, but we would like to make them available only if the user is registered in the application. We already have a site configured to handle the login process, etc. I just can't figure out how to route static files through Symfony so I can use this security process to check if the user is allowed to view files.
I know that Symfony is configured so that static files are automatically maintained, so I modified the htaccess file to include this:
All that is , and the file is not in the directory "guide" should just be serviced.
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{REQUEST_URI} !/guides/
RewriteRule .? - [L]
Then I tried to make a route that can catch all the URLs coming from this directory and go through a special controller where I can check Authorized users and redirect to login if it’s bad, or show the actual page if it’s good.
support_guides:
path: /guides/{the-rest}
defaults: { _controller: MillenniumSIMeevoSupportBundle:HelpGuide:show }
Htaccess seems to work (I think) as it is not trying to serve the page directly, but now I just get the Symfony 404 page.
source
share