There are several reasons you might need to take a website offline – scheduled maintenance, a security incident, a rebuild or a permanent closure. The method you choose depends on whether you need temporary or permanent downtime, and whether you still need to access the site yourself during that time.
Four methods are covered below: restricting access by IP address, enabling a maintenance page redirect, changing your DNS records and removing your website files. Each produces a different result, so read through the options before deciding which suits your situation.
This method blocks all visitors except those connecting from a specific IP address. It is the best option when you need to continue working on the site yourself while keeping it hidden from the public. Your site files remain in place and the server continues to serve the site – only access is restricted.
.htaccess file./public_html/. If .htaccess is not visible, click Settings in the top-right corner and tick Show Hidden Files..htaccess and select Edit.YOUR.IP.ADDRESS.HERE with your actual public IP address.Order deny,allow
Deny from all
Allow from YOUR.IP.ADDRESS.HERE
Allow from line for each one.
To restore public access, remove the three lines you added and save the file again.
A maintenance page redirect keeps your site technically online but sends all visitors to a holding page. This is preferable to a blank error for short-term downtime because it communicates clearly that the site will return. A 307 temporary redirect tells search engines not to update their index.
/public_html/ and create a new file named maintenance.html. Add a short message for your visitors explaining that the site is temporarily unavailable..htaccess file..htaccess and select Edit.RewriteEngine On
RewriteCond %{REQUEST_URI} !^/maintenance.html$
RewriteRule ^(.*)$ /maintenance.html [R=307,L]
When your site is ready to go back online, remove the three RewriteEngine lines from .htaccess and save. You can leave maintenance.html in place for future use.
Changing your DNS records stops your domain from resolving to your server at all. This takes the site offline at the network level, regardless of what files are on the server. DNS changes take time to propagate – typically between a few minutes and 48 hours – so this method is not suitable when you need an immediate result.
A record pointing your domain (and the www subdomain) to your server’s IP address.192.0.2.1 (a reserved, non-routable address). Avoid using 127.0.0.1 as this resolves to localhost on the visitor’s own machine and can produce misleading errors.To bring the site back online, restore the A record to your server’s original IP address. See our guide on editing your DNS zone for full instructions, and our guide on checking DNS propagation to monitor when the change takes effect.
Removing or relocating your website files from the public directory causes the server to return a 404 error to all visitors. This is the most disruptive option and should only be used when you intend to permanently take the site down or are certain you have a complete backup. Do not use this method for temporary maintenance.
/public_html/, then click Compress to create an archive. Download the archive to your local machine before proceeding. See our guide on backing up and restoring with JetBackup for a full account-level backup./public_html/ and select the files and folders that make up your website./backup_site/ at the account root level (outside /public_html/). Moving is safer if there is any chance you will need to restore the site.
Once the files are removed, visitors will receive a 404 error. If you have a custom 404 page configured, that page will be displayed instead.
If visitors can still access your site after editing .htaccess, the file may not have saved correctly, or a caching layer is serving a cached version of the page.
.htaccess file – add-on domains and subdomains may have their own .htaccess in a subdirectory.An infinite redirect loop occurs when the RewriteCond line is missing or incorrect, causing the maintenance page itself to be redirected.
RewriteCond %{REQUEST_URI} !^/maintenance.html$ – the ! at the start is required.maintenance.html is in the root of /public_html/ and not inside a subdirectory.RewriteEngine On already appears earlier in your .htaccess file, remove the duplicate line from the block you added.DNS propagation is not instant. If your site still resolves after changing the A record, the change may not have reached all DNS resolvers yet.
You now have four ways to take a website offline: IP-based access restriction, a maintenance page redirect, a DNS-level change and file removal. Each suits a different scenario – IP restriction and maintenance redirects work well for temporary downtime, while DNS changes and file removal are better suited to longer-term or permanent situations.
For related tasks, see our guides on editing your DNS zone, using cPanel File Manager, backing up and restoring files with JetBackup and fixing website error codes.
Launch your website with our reliable cPanel hosting with unlimited bandwidth and expert support.
Get cPanel Hosting