: Website is under maintenance - how to restrict access? Currently, my website is under maintenance. I want to be the only person who's able to access/view the website online until I finish maintenance.
Currently, my website is under maintenance. I want to be the only person who's able to access/view the website online until I finish maintenance. How to set restrictions to others? I hate stalkers.
More posts by @Looi9037786
2 Comments
Sorted by latest first Latest Oldest Best
Currently my website is under maintenance.
If your website is only temporarily "under maintenance" and has already been live and indexed by search engines then you should consider returning a "503 Service Unavailable" HTTP response code with perhaps a Retry-After HTTP header indicating when the site is expected to be available again. Instead of simply blocking access to the site with a 401 or 403 response.
The 503 response is specifically for situations when the site is "down for maintenance" and can help lessen the effect any downtime might have on your search engine ranking.
This is easily achieved using mod_rewrite (and mod_headers) in htaccess in order to block IP addresses. However, as mentioned in comments above, blocking IPs (or rather only allowing a select few IPs) can be problematic unless the IPs you are allowing are (reasonably) static or you can allow IP-ranges (if your content isn't too sensitive).
To achieve something like this in htaccess:
# Declare custom error document
ErrorDocument 503 /errordocs/e503.php
RewriteEngine On
RewriteCond %{REMOTE_ADDR} !=123.123.123.123
RewriteCond %{REMOTE_ADDR} !=124.124.124.124
RewriteCond %{ENV:REDIRECT_STATUS} !=503
RewriteRule .* - [R=503,L]
Only the IPs 123.123.123.123 and 124.124.124.124 will be allowed access. Then to send an unconditional Retry-After header:
Header set Retry-After "Wed, 25 Dec 2013 04:00:00 GMT"
(This could be sent conditionally based on the value of an environment variable for instance.)
However, personally I tend to pass the date/time directly to my error document and allow my script to set the header conditionally and display a meaningful message to the user at the same time (this would also be reqd if you didn't have mod_headers installed):
# Declare custom error document, passing date/time for Retry-After header
ErrorDocument 503 /errordocs/e503.php?RetryAfter=2013-12-25+04:00:00
I can see that you selected "cpanel" as a tag. In your cPanel you should have an option to password protect directories. It looks like this:
There you can setup a username and password for your website root.
In this way only people that have the right credentials can see the site.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.