Home Website Tutorials Block website access by specific date and time

Block website access by specific date and time

by Thạch Phạm
Published: Last Updated on
A+A-
Reset

Introduction

In some cases, if you need to edit the code or for some reason, you want to block users from accessing your website for a certain period but do not know how, then this article is the solution for you.

Configuration Guide

NOTE: Check the system Date-Time before using the rules. Because the rules will be calculated according to the system Date-Time.

Block access by a specific date

The following are the TIME_WDAY values corresponding to the days of the week:

Block website access by specific date and time
Once you understand the structure, you can follow the instructions below.

For example, I will block website access on Sunday, and the corresponding TIME_WDAY value is 0.

Now I access the Document root of the website that needs to be blocked, find and open the .htaccess file of the website, and add the following rule:

# Chặn truy cập website vào ngày Chủ nhật.
RewriteCond %{TIME_WDAY} ^0$
RewriteRule ^.*$ - [F,L]

Here is the content when added:

Block website access by specific date and time

And the access result shows 403 Forbidden as successful.

Block website access by specific date and time
Error 403 is access block

Block access by a specific time

Below are the parameters and their definitions that you need to pay attention to.

Block website access by specific date and time
Once you understand the structure, you can follow the instructions below.
  • Block a specific time frame (calculated time: 24 hours 1h > 24h)

For example, I will block website access at a specific time frame: 13 o’clock. Then the blocking structure would look like this:

NOTE: When you choose 13 hours, the application time will be calculated from 13h00 > 13h59.

# Chặn truy cập website vào 13 giờ.
RewriteCond %{TIME_HOUR} ^13$
RewriteRule ^.*$ - [F,L]

Here is the content when added:

Block website access by specific date and time

And the access result shows 403 Forbidden as successful.

Block website access by specific date and time
Error 403 is access block
  • Block many different time frames

For example, I will block website access in the time frames: 13h0014h00 – 15h00. Then the blocking structure would look like this:

# Chặn truy cập website nhiều khung giờ.
RewriteCond %{TIME_HOUR} ^(13|14|15)$
RewriteRule ^.*$ - [F,L]

Here is the content when added:

Block website access by specific date and time

Above are some ways that you can apply to block users from accessing your website automatically without doing it manually as before. Hope this article will help you.

You can refer to other instructions at the link below:

If you need assistance, you can contact support in the ways below:

Đánh giá

Tham gia nhóm hỗ trợ Server - Hosting

Tham gia nhóm Hỗ trợ Server - Hosting & WordPress để cùng nhau hỏi đáp và hỗ trợ các vấn đề về WordPress, tối ưu máy chủ/server.

Tham gia ngay

Bài viết cùng chuyên mục

AZDIGI – Không chỉ là đơn vị hàng đầu trong lĩnh vực Web Hosting và Máy chủ, chúng tôi mong muốn mang lại những kiến thức bổ ích nhất và luôn cập nhật thường xuyên cho cộng đồng người đam mê thiết kế website, công nghệ,…

Vui lòng không sao chép nội dung nếu chưa xin phép. Designed and Developed by PenciDesign