Reputation: 661
I started to make a website and i want to use only decoupled components (installed through composer) that i will need in my project. The first component i want to use is symfony/routing component. So i made a php file (the front controller) and i want all user requests to be redirected to this front controller. What best practices to do that?
I tried it to do with the .htaccess file like this:
RewriteEngine on
RewriteRule ^.*$ frontController.php [L]
So any request will be redirected to the front controller. But is it secure and well written? Maybe there is some best practices for cases like this?
Upvotes: 0
Views: 257
Reputation: 4265
This tutorial will be perfect for your needs: http://symfony.com/doc/current/create_framework/index.html
Especially the routing part: http://symfony.com/doc/current/create_framework/routing.html
Regarding your specific question, you may want to add a few more rules before, e.g. if a file exists do not redirect but just serve the file
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule .? - [L]
The .htaccess included in Symfony Standard Edition is a good example.
Upvotes: 1