biggieuk Posted November 17, 2011 Share Posted November 17, 2011 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 Quote Link to comment Share on other sites More sharing options...
joe92 Posted November 17, 2011 Share Posted November 17, 2011 Not entirely sure on the rules of the regex you want, but try this; preg_match("/[\d]+\.[\w]+\./", $_SERVER['HTTP_HOST'], $vresult) Quote Link to comment Share on other sites More sharing options...
biggieuk Posted November 17, 2011 Author Share Posted November 17, 2011 Seems to work great, thanks alot! Quote Link to comment Share on other sites More sharing options...
xyph Posted November 17, 2011 Share Posted November 17, 2011 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.