Restriction to an environment

Hello, can anyone help me with restriction of users to an environment? I’m a bit new to these stuff so pardon my ignorance :)

Here is my situation:

My test and production environment are on the same server

and lets say my urls will be as follows:

test =

prod =

So the situation are as follows:

  • prod will be accessed publicly (no problem here)

  • test should not be publicly accessible

  • test may have some remote users who can access it

  • those remote users doesn’t have static ip

i wanted to do this at my VirtualHost level, but i don’t know if this is possible and i don’t want to go to htaccess and htpasswd authentication

If this is not possible, can we do this at yii level? like restricting for gii using "allowedIps"? if yes, is this a good implementation???

what do you suggest me to do in my situation?

how do you guys manage your different environments?

What web server are you running? If you’re using Apache, you can do it from a VirtualHost directive:

You mention users don’t have static IPs. You’d run in to the same problems on a Yii level as a server level. You’re going to have to account for wildcards at some point, may as well implement it from the server.

Im using apache.

Could you explain how can i do this in my virtual host?