apache_conf 修改后的Symfony2 .htaccess文件,可以从Apache虚拟主机设置前端控制器(有点像Rails)。

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了apache_conf 修改后的Symfony2 .htaccess文件,可以从Apache虚拟主机设置前端控制器(有点像Rails)。相关的知识,希望对你有一定的参考价值。

<IfModule mod_rewrite.c>
    RewriteEngine On

    ### Call the correct front controller. This is dependent on an environment variable being set
    ### in the virtual host configuration. SetEnv seems not to work, so here's an example with SetEnvIfNoCase:
    ###   <Directory /path/to/application/web>
    ###     SetEnvIfNoCase REQUEST_URI .* SYMFONY_ENV=dev
    ###   </Directory>
    ### This will force the following rules to call the dev front controller.

    # Make sure the prod front controller is called without a suffix.
    # (prod OR production) and file doesn't exist
    RewriteCond %{ENV:SYMFONY_ENV} prod [OR]
    RewriteCond %{ENV:SYMFONY_ENV} production
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ app.php [QSA,L]

    # dev
    RewriteCond %{ENV:SYMFONY_ENV} dev [OR]
    RewriteCond %{ENV:SYMFONY_ENV} development
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ app_dev.php [QSA,L]

    # any other front controller
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{ENV:SYMFONY_ENV} ^(.+)$
    RewriteRule ^(.*)$ app_%1.php [QSA,L]

    # Default to prod if there is no variable set (most secure)
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ app.php [QSA,L]
</IfModule>

以上是关于apache_conf 修改后的Symfony2 .htaccess文件,可以从Apache虚拟主机设置前端控制器(有点像Rails)。的主要内容,如果未能解决你的问题,请参考以下文章

apache_conf 评论déporterlasession sous Symfony2。

Symfony2 ACL 结合另一个条件

Symfony2 子域防火墙在生产服务器上被忽略

在 Symfony2 中将多维数组转换为点表示法

Symfony2 - 创建自己的供应商包 - 项目和 git 策略

使用doctrine从Symfony2中的外部数据库导入表