简体   繁体   English

Symfony2:在 app.php 和 app_dev.php 之间切换,我这样做对吗?

[英]Symfony2 : Switching between app.php and app_dev.php, am I doing it right?

I'm currently setting up symfony2 on a remote server that we'll call www.domain.com.我目前正在远程服务器上设置 symfony2,我们将其称为 www.domain.com。

I want all my user that call the address www.domain.com to be redirected to www.domain.com/app.php , so I wrote a RewriteRule, and it's working fine.我希望所有调用地址 www.domain.com 的用户都被重定向到www.domain.com/app.php ,所以我写了一个 RewriteRule,它工作正常。

Now I still want our developers to access the app_dev.php on the domain www.domain.com, so I created the following subdomain : www.dev.domain.com that has a specific RewriteRule to redirect to app_dev.php现在我仍然希望我们的开发人员访问域 www.domain.com 上的 app_dev.php,所以我创建了以下子域: www.dev.domain.com具有特定的 RewriteRule 重定向到 app_dev.php

My setup is working fine, but it look like kind of hacky so I was wondering if there's a better way to achieve that ?我的设置工作正常,但看起来有点像hacky,所以我想知道是否有更好的方法来实现这一目标?

Here's my RewriteRules :这是我的 RewriteRules :

        RewriteCond %{HTTP_HOST} ^(domain.com|www.domain.com)
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^(.*)$ web/app.php [QSA,L]

        RewriteCond %{HTTP_HOST} ^(www.dev.domain.com|dev.domain.com)
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^(.*)$ web/app_dev.php [QSA,L]

Thanks !谢谢 !

Well, it sound a little bit tricky but it's fine.嗯,这听起来有点棘手,但没关系。
Another thing is: If you've created a subdomain (dev.domain.com), why don't you do this subdomain be an entirely project for developers?另一件事是:如果您已经创建了一个子域 (dev.domain.com),为什么不将该子域完全作为开发人员的项目呢?
I mean, doing the trick with .htaccess if the developers make changes to the code these changes will be directly done also in production.我的意思是,如果开发人员对代码进行更改,则使用 .htaccess 进行操作,这些更改也将直接在生产中完成。
If you've 2 projects with one in production (domain.com with the app.php) and another for development (dev.domain.com with app_dev.php) the developers will have the possibility to develop freely without worrying for the consequences on production environment.如果您有 2 个项目,其中一个在生产中(domain.com 带有 app.php),另一个用于开发(dev.domain.com 带有 app_dev.php),则开发人员将有可能自由开发,而无需担心后果生产环境。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM