简体   繁体   中英

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.

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.

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

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 ?

Here's my 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?
I mean, doing the trick with .htaccess if the developers make changes to the code these changes will be directly done also in production.
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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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