Can this be done? (IP dependant directories from same URL)

I’m hosted on Unix and have the following folders:
/home/me/dev (development site)
/home/me/live (final live site)

vhosts is pointing to the mydomain.com directory and I have a symbolic link pointing to the required folder:
ln -s /home/me/dev mydomain.com

This allows me to run tests in /dev without messing with the live site files. When happy I push my changes over to /live. If I want to check /live I just change the symbolic link to /live.

Of course I can only point a symbolic link to one directory at a time.

After launch, I will need to be pointing to /home/me/live/ but would still like to develop in the /dev folder when necessary.

Question:
Is it possible to configure Apache or Unix so, when visiting mydomain.com, it will read my ip address and serve me /home/me/dev/ whilst the rest of the world are served /home/me/live ?

Why not use dev.mydomain.tld and have it point to the dev location while everything else concerning mydomain.tld points to the live section? (You do not want your IP going to the dev instead of the live, like you asked for. How would you review the live site if a problem is reported?)

There are a few reasons for not wanting to use a subdomain. I have other setups where i am doing just that but in this instance I would need to set it up as described.

If a problem was reported on the live site I would simply take away the IP condition and access it like everyone else.

It might be best to re-define my request to determine whether there is ANY way to use ANY conditional statement to point to separate directories? If that is possible I can move on to look into how I might pass that condition my ip address.

Anyone have any ideas?

So you just want to create an over complication…for no real reason? o.O

Oh dear. So by saying there are a few reasons and not specifying them, you assume that they aren’t real and then go on to patronise by calling this ‘wanting to be overcomplicated’?

I am simply asking for any HELPFUL advice from anyone that has a better understanding of apache and vhosts without going into details of WHY as that would bloat this thread and move away from being a discussion about HOW.

If specifying reasons is the only way to get advice on the matter I will specify one to give proof that they are valid and say that there are others equally important.

Reason One of Many:
I have an SSL certificate on the site that would not work with a subdomain as it is not a wildcard certificate. I can not overcome this with a self-signed certificate as a device that will use it does not work with self-signed certificates.

So, getting back to the question, can someone please provide any info on HOW this might be done. A more helpful response than the last one would be a simple ‘CAN or CANT because’.

Thanks

No, it is not possible, which is why I am "patronise" because it is not possible.

haris,

You can use mod_rewrite to examine Apache’s {REMOTE_ADDR} variable and make a redirection based on that.

I’m sure that there must be something else in your question, though, that I’m not sure can be accounted for with mod_rewrite’s redirection although I can’t imagine what it might be. Just pop the mod_rewrite code into your .htaccess file in the DocumentRoot (of the domain) and that should be it. Try:

RewriteEngine on
RewriteCond %{REMOTE_ADDR} ^123\\.123\\.123\\.123$ # Your IP address - I hope you have a fixed IP address
RewriteRule .? dev%{REQUEST_URI} [L]

NOTA BENE: This will fall over if live is the DocumentRoot because dev is outside your webspace - move dev under live and alter the RewriteRule regex to !^dev/.

Regards,

DK