tags:

views:

43

answers:

1

Is there a way to detect if the site is running under a web server and local server.

+2  A: 

Check $_SERVER['SERVER_ADDR']

stillstanding
+1, check that variable and match it against the ip ranges that are reserved for local/private use like "192.168.*.*" or "10.*.*.*" etc, etc.
Techpriester
There's also `$_SERVER['HTTP_HOST']` if the devel and live servers have different names. Might be somewhat more portable, especially if the live server is actually a cluster with multiple IPs
Marc B