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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.