Today in this tutorial we will learn how to set maintenance page in PHP based website.In this example publicly
the website will show maintenance page for all but the maintenance page will not be visible for your network. In other words,from your network you will see complete website (not maintenance page).The developer and system admin can work from their network and it helps them to debug the issue before going live again.

Logic: In this scenario we will use the logic, if website traffic is not coming from particular iP address then show maintenance page else do not show maintenance page.
Now here you get two cases,what if your network ip address, which is coming from Proxy server or network.
For these two cases I have given example code.
To know about your IP address you can use myip.sharadchhetri.com.

How To:

Step 1: Edit index.php (DirectoryIndex) file and after first line ofphp tag ,paste the given below code as per your case.

Note: Replace 192.241.190.251 with the ip address which you got from https://www.whatismyip.com/

If your network is NOT behind the proxy

If your network is NOT behind the proxy then use below given code
Use code from line no. 3 to 6


OR

If your network is behind the Proxy

If your network is behind the Proxy then use below given code (then do not use above given code)
Use code from line no. 3 to 6


Step 2: Create Maintenance page with file name called maintenance.php in DocumentRoot (where your index.php DirectoryIndex is located)

Simple maintenance.php file.(You can get beautiful maintenance pages just google it)

vi maintenance.php



Read Some More Articles

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.