HoangSon.Io.Vn
  • Trang chủ
  • Smart Home
  • Máy Tính
  • Kiếm Tiền Online
  • Webmaster
  • WordPress
    • Plugin WordPress
    • Theme WordPress
    • Thủ Thuật WordPress
  • Điện Thoại
No Result
View All Result
  • Trang chủ
  • Smart Home
  • Máy Tính
  • Kiếm Tiền Online
  • Webmaster
  • WordPress
    • Plugin WordPress
    • Theme WordPress
    • Thủ Thuật WordPress
  • Điện Thoại
No Result
View All Result
HoangSon.Io.Vn
No Result
View All Result
Trang Chủ Blog

Sử dụng htaccess

Admin by Admin
27/09/2013
in Blog, IT
0
Sử dụng htaccess 1
0
SHARES
20
VIEWS
Chia sẻ lên FacebookChia sẻ lên Twitter

 

Sử dụng file .htaccess để tối ưu và bảo mật website của bạn hơn: bảo vệ các file quan trọng, giới hạn upload, chuyển hướng 301, trang lỗi tùy chỉnh, tắt liệt kê nội dung thư mục, nén nội dung…
Chức năng:
1. Bảo vệ tệp tin
2. Tắt chữ ký số của web server
3. Giới hạn upload
5. Giới hạn quyền truy cập
6. Trang lỗi tùy chỉnh
7. Tắt liệt kê nội dung thư mục
8. Chuyển hướng 301
9. Chống ăn cắp băng thông như hình ảnh, video (bandwidth)
10. Bật nén PHP compression (bandwidth)
11. Thiết lập canonical url cho website

1.Bước 1, Tạo file .htaccess.
Mở Notepad hoặc phần mềm text editor. Lưu và Đặt tên file htaccess.txt.
2. Nhập nội dung vào file htaccess.txt.

# Bảo vệ file file htaccess
<files .htaccess>
order allow,deny
deny from all
</files>
#Tắt chữ ký số của web server
# disable the server signature
ServerSignature Off
# limit file uploads to 10mb
LimitRequestBody 10240000
# Bảo vệ file cấu hình config.php
<files config.php>
order allow,deny
deny from all
</files>
# Giới hạn truy cập, chặn IP
order allow,deny
#deny from 000.000.000.000
allow from all
# Tạo Trang lỗi tùy chỉnh

# custom error docs
ErrorDocument 404 /notfound.php
ErrorDocument 403 /forbidden.php
ErrorDocument 500 /error.php
# Tắt liệt kê nội dung thư mục
Options All -Indexes
# Chuyển hướng 301
Redirect 301 /old.php http://www.yourdomain.com/new.php
# Khóa tên miền tham chiếu
RewriteEngine on
RewriteCond %{HTTP_REFERER} digg.com [NC] RewriteRule .* – [F] Chống ăn cắp băng thông

#disable hotlinking of images with forbidden or custom image option
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www.)?yourdomain.com/.*$ [NC] #RewriteRule .(gif|jpg)$ – [F] #RewriteRule .(gif|jpg)$ http://www.yourdomain.com/stealingisbad.gif [R,L] Nén file

# php compression – use with caution
<ifmodule mod_php4.c>
php_value zlib.output_compression 16386
</ifmodule>
Tránh trùng lặp nội dung

# set the canonical url
RewriteEngine On
RewriteCond %{HTTP_HOST} ^yourdomain.com$ [NC] RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [R=301,L] # Chống spam comments
RewriteEngine On
RewriteCond %{REQUEST_METHOD} POST
RewriteCond %{REQUEST_URI} .comments-post.php*
RewriteCond %{HTTP_REFERER} !.*yourdomain.com.* [OR] RewriteCond %{HTTP_USER_AGENT} ^$
RewriteRule (.*) ^http://%{REMOTE_ADDR}/$ [R=301,L]

3. Upload htaccess.txt lên server.
Sử dụng ftp client (sử dụng ASCII mode) và đổi tên file là .htaccess.
CHMOD file .htaccess sang 644.

 

Đánh giá post
Tags: htaccess
Bài trước

Giải quyết lỗi /usr partition 100% full

Bài tiếp theo

Backup full hosting và vps thông qua SSH

Admin

Admin

HoangSon.Us

Liên quanBài đăng

Các câu lệnh xóa archive log trong Oracle
IT

Check process ID từ port trong Linux, Solaris

01/11/2024
16
Không cho Chrome tự động redirect sang https
Hệ Điều Hành

Không cho Chrome tự động redirect sang https

24/07/2024
28
8,5 triệu thiết bị chạy windows bị màn hình xanh bởi CrowdStrike update và giải pháp tạm thời
Hệ Điều Hành

8,5 triệu thiết bị chạy windows bị màn hình xanh bởi CrowdStrike update và giải pháp tạm thời

22/07/2024
30
Cách kết nối với PC ở nhà từ xa thông qua ngrok (không cần mở port router)
IT

Cách kết nối với PC ở nhà từ xa thông qua ngrok (không cần mở port router)

10/08/2023
37
Sử dụng htaccess 2
Docker

Sync time, time zone docker container

19/03/2023
21
GoAccess, Real Time Dashboard monitor for Nginx Proxy Manager – Docker
Docker

GoAccess, Real Time Dashboard monitor for Nginx Proxy Manager – Docker

19/03/2023
43
Bài tiếp theo
Hướng dẫn lắp ráp PC đơn giản và chi tiết

Backup full hosting và vps thông qua SSH

Trả lời Hủy

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *

  • Trending
  • Bình luận
  • Mới nhất
Cách Active Windows 10 kích hoạt bản quyền số vĩnh viễn

Cách Active Windows 10 kích hoạt bản quyền số vĩnh viễn

02/09/2020
Khắc phục lỗi Wifi báo No Internet, Secured trên Windows 10 2004

Khắc phục lỗi Wifi báo No Internet, Secured trên Windows 10 2004

11/08/2020
Hướng dẫn cách cài lại Windows 10 từ ổ cứng chi tiết

Hướng dẫn cách cài lại Windows 10 từ ổ cứng chi tiết

30/07/2020
Hướng dẫn tải và cài đặt driver card màn hình VGA NVidia

Hướng dẫn tải và cài đặt driver card màn hình VGA NVidia

29/07/2020
Cách Active Windows 10 kích hoạt bản quyền số vĩnh viễn

Cách Active Windows 10 kích hoạt bản quyền số vĩnh viễn

49
Khắc phục lỗi Wifi báo No Internet, Secured trên Windows 10 2004

Khắc phục lỗi Wifi báo No Internet, Secured trên Windows 10 2004

18
Share plugin Elementor Pro v3.0.3 WordPress update liên tục

Share plugin Elementor Pro v3.0.3 WordPress update liên tục

17
Chia Sẻ Theme Newspaper By Tagdiv Update Liên Tục

Chia Sẻ Theme Newspaper By Tagdiv Update Liên Tục

10
FIX update, INSTALL package sau khi vòng đời CentOS 7 ngừng hỗ trợ

FIX update, INSTALL package sau khi vòng đời CentOS 7 ngừng hỗ trợ

22/04/2025
Code Pzem lên Hass Home Assistant ESPHOME

Code Pzem lên Hass Home Assistant ESPHOME

30/03/2025
Code sunsynk-power-flow-card cho luxpython – Home Assistant

Đưa thông tin Luxpower lên Home Assistant dùng LuxPython

30/03/2025
Cài đặt Home Assistant

Cài đặt Home Assistant

29/03/2025

Cập nhật

FIX update, INSTALL package sau khi vòng đời CentOS 7 ngừng hỗ trợ

FIX update, INSTALL package sau khi vòng đời CentOS 7 ngừng hỗ trợ

22/04/2025
2
Code Pzem lên Hass Home Assistant ESPHOME

Code Pzem lên Hass Home Assistant ESPHOME

30/03/2025
5
Code sunsynk-power-flow-card cho luxpython – Home Assistant

Đưa thông tin Luxpower lên Home Assistant dùng LuxPython

30/03/2025
11
Cài đặt Home Assistant

Cài đặt Home Assistant

29/03/2025
3
Các câu lệnh xóa archive log trong Oracle

Check process ID từ port trong Linux, Solaris

01/11/2024
16
Code pzem cho esphome

Code pzem cho esphome

25/03/2025
55
  • Liên Hệ
  • Giới thiệu
  • Chính sách bảo mật
SON

© 2020 bản quyền thuộc về SON

No Result
View All Result
  • Trang chủ
  • Smart Home
  • Máy Tính
  • Kiếm Tiền Online
  • Webmaster
  • WordPress
    • Plugin WordPress
    • Theme WordPress
    • Thủ Thuật WordPress
  • Điện Thoại

© 2020 bản quyền thuộc về SON