php - Symfony omit filename for routing -
i pretty new symfony , learning it. though symfony's documentation has helped me of concerns , answered questions i've had far, wasn't able find solution question regarding routing.
whenever access page, need specify front-controller in order trigger routing:
http://localhost/symfony/app_dev.php/test
what want clean url further omitting front-controller:
http://localhost/symfony/test
this might simple thing, haven't been able find single question or documentation page describes me how (if it's @ possible). have tried renaming front-controller index.php, unfortunately doesn't work either.
if httpd.conf says allows overriding
namevirtualhost *:80 <virtualhost *:80> servername foo.localhost.com documentroot "/projects/yourproject/web" <directory "/projects/yourproject/web"> options indexes followsymlinks allowoverride allow </directory> </virtualhost>
you can use web/.htacces
# use front controller index file. serves fallback solution when # every other rewrite/redirect fails (e.g. in aliased environment without # mod_rewrite). additionally, reduces matching process # start page (path "/") because otherwise apache apply rewriting rules # each configured directoryindex file (e.g. index.php, index.html, index.pl). directoryindex app.php <ifmodule mod_rewrite.c> rewriteengine on rewritecond %{request_uri}::$1 ^(/.+)/(.*)::\2$ rewriterule ^(.*) - [e=base:%1] rewritecond %{env:redirect_status} ^$ rewriterule ^app.php(/(.*)|$) %{env:base}/$2 [r=301,l] ##### part should tweak, have .htaccess point request app_dev.php, since routing.yml empty rewritecond %{request_filename} -f rewriterule .? - [l] rewriterule .? %{env:base}/app_dev.php [l] ##### part should tweak, have .htaccess point request app_dev.php, since routing.yml empty </ifmodule> <ifmodule !mod_rewrite.c> <ifmodule mod_alias.c> # when mod_rewrite not available, instruct temporary redirect of # startpage front controller explicitly website # , generated links can still used. redirectmatch 302 ^/$ /app_dev.php/ # redirecttemp cannot used instead </ifmodule> </ifmodule>
be sure ifmodule enabled; link
so in prod environment replace app_dev.php app.php
you may want have different parameters each environment, best put .gitignore , create 2 files :
parameters.prod.yml parameters.dev.yml
and depending on stage create parameters.yml file symbolic link in same dir :
ln -s parameters.dev.yml parameters.yml
Comments
Post a Comment