2

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 !

1
  • Looks good to me, just remember to secure dev environment. Commented Sep 2, 2015 at 8:22

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for the feeback, It's actually what I wanted to have the exact same code in dev.xxx.com and xxx.com as we already have a local dev environment, but that would be an interesting set up as well !
You're welcome. I've this exactly setup in my projects and it's really easy and useful to work with it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.