There are several ways to do this, one would be using a list of allowed IP addresses in the .htaccess file…. But, if you want something simple, that can be accessed anywhere, by anyone you want to have access, then we can simply create a ‘dev’ mode. To access the site, we just add ‘?dev=1‘ at the end of the url, i.e. ‘www.mydomain.com/?dev=1′.
Open the page.tpl.php file and add this code at the very top, so that the end ?> is followed immediately by the HTML declaration, i.e. <!DOCTYPE html PUBLIC etc.
<?php if(isset($_GET['dev']) && $_GET['dev']==1){ $_SESSION['dev'] = true; } if(isset($_GET['dev']) && $_GET['dev']==0){ $_SESSION['dev'] = false; } if(!isset($_SESSION['dev']) || $_SESSION['dev']!=true){ echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Page Under Construction</title> </head> <body> <p>This site is under construction</p> </body> </html>'; exit(); } ?>
If you visit the site without setting anything, (or if you reset ‘dev mode’ by using ‘?dev=0‘), you’ll just get the ‘Under construction’ text. This of course can be replaced with include files, etc…
By IP Address
If you wanted to do the same thing using your IP address, use this code instead:
<?php if($_SERVER['REMOTE_ADDR'] != '123.45.67.890'){ echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Page Under Construction</title> </head> <body> <p>This site is under construction</p> </body> </html>'; exit(); } ?>