Jump to content

Determine if website matches development server url


biggieuk

Recommended Posts

Hi all,

 

I have a PHP snippet that determines which state the website is in. LOCAL/ TEST or LIVE:

 

if($_SERVER['REMOTE_ADDR'] == '127.0.0.1') $state = 'LOCAL';
elseif(preg_match(".............<Not sure>..............", $_SERVER['HTTP_HOST'], $vresult)) $state = 'TEST';
else $state = 'LIVE';

 

Im struggling with the preg_match section to determine if the website is on a development server. The development servers are structured like so:

 

devXX.WEBSITE.com

 

XX - any number

WEBSITE - the website name for my dev server

 

any help with this would be greatly appreciated.

 

Thanks

You generally want direct control over the status of your website. Have some sort of SITE_STATUS constant defined in a config file, and include it.

 

If the constant ==

0 - Down for maintenance

1 - Live

2 - Test

3 - Local

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.