Create a 503 Status Code for your Site

With any hosting account, there is always a chance of something going wrong and keeping your files from displaying properly. Perhaps your site was hacked and you need some time to restore or clean compromised files. Or maybe you need to take your site down to perform some extended maintenance. In either case, you want to let the customers know you will be back. Just as important, you want to let the search engines know that you are down temporarily and will return. This way they will neither penalize your site nor remove your pages from their index. Here we discuss the proper way to let everyone know using a 503 setting for your cPanel account.

NOTE: This will not work if there is no communication with the server itself. This is for instances when the server is up and running but there is something wrong with the account or files.

A Note About HTTP Codes

Whenever you visit a web page, your browser receives a code from the server. These codes are known as HTTP status codes. Below are some of the most important and common ones.

200 – The HTTP request was successful. This is the expected response.

301 Moved Permanently – This means the requested file has moved to another permanent location. All future requests for this resource should be directed to the new location.

302 Found – The requested file or resource has moved temporarily. This code tells the search engines that the redirect is temporary, as opposed to the 301 redirect. This code will not pass any link juice.

404 Not Found – Most of us are familiar with this code. A 404 error code means the requested item cannot be found at the location and no redirect was given. This code is not known to be either permanent or temporary. Eventually, the file will be removed from the search engine indexes.

503 Service Unavailable – This code means the server is currently unavailable. This could be due to a server overload, in which the server will give out the 503, or the site is under maintenance. Search engines that receive this code know that the situation is temporary. This is the code you should use when your site is under maintenance or undergoing extensive work and needs to be offline.

Advising the Search Engines of your Temporary Situation

If a situation occurs where you need to take the site down temporarily, you will want to let Google and other search engines know. To do this, you would use the 503 status code you read about above. There are a couple of steps to take to set this up.

Create a 503.php file

First, you will want to create a file named “503.php”. This file can serve as a notification for both the servers as well as your human visitors. For the search engines, you will need to place some code at the top of the file. You can copy the code below:

header("HTTP/1.1 503 Service Temporarily Unavailable");
header("Status: 503 Service Temporarily Unavailable");
header("Retry-After: 3600");

The first two lines define the 503 code. The third line defines when the site is expected to be back. In this case, the number is given in seconds. 3600 seconds is one hour. In some cases, you may want to give a specific date. In that case, you would use the following line instead:

header("Retry-After: Fri, 27 May 2016 12:00:00 GMT");

This line must be given in Greenwich Mean Time (GMT) so you may want to adjust it for your specific time zone.

Once you set the code to let the search engines know about your situation, you can add code to let your visitors know. This can be written with simple HTML such as the following:

header("HTTP/1.1 503 Service Temporarily Unavailable");
header("Status: 503 Service Temporarily Unavailable");
header("Retry-After: 3600");
<!DOCTYPE html>
<title>Site is temporarily unavailable due to maintenance</title>
<h1>Site is temporarily unavailable due to maintenance</h1>
<p>We expect to have the site back up within 4 hours.</p>

Set the redirect in .htaccess

Now that the php file has been created, you will need to set the redirect within your .htaccess file. This way any requests to the site get redirected to it. For those who have some experience creating 301 redirects in the .htaccess file, this will be similar.

  1. Log into your cPanel.
  2. Open the .htaccess file for editing using the File Manager.
  3. Add he following code to the top of the file:
    Options +FollowSymLinks
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REMOTE_ADDR} !^00\.00\.00\.00
    RewriteCond %{REQUEST_URI} !^/503/php [NC]
    RewriteRule .* /503.php [L,R]
  4. Save the file.

If you personally want to have access to the site while everyone else sees the 503, you can edit the fourth line to include your IP address. This way you can see the site and any changes you make normally. So, for instance, if your IP address was, you would make the fourth line above look like this:

RewriteCond %{REMOTE_ADDR} !^123\.123\.123\.123


  • Thank you so much. You will be surprised at how hard it is to find “Create a 503 Status Code for your Site” when making a Google search. Your page was the first after adjusting my search phrase several times.

Was this article helpful? Let us know!