Apache & ModRewrite: How to easily deny access to a folder with htaccess Apache & ModRewrite: Làm thế nào để từ chối một cách dễ dàng truy cập vào một thư mục với htaccess
Posted on 17. Được đăng trên 17. Jul, 2009 by Dragos in Apache & mod_rewrite , Coding Tháng Bảy, 2009 bởi Dragos trong Apache & mod_rewrite, Coding
Working on a project right now I was looking for a solution to protect a folder containing template php files (includes in larger files). Làm việc trong một dự án ngay bây giờ tôi đang tìm kiếm một giải pháp để bảo vệ một thư mục chứa file php mẫu (bao gồm trong các tập tin lớn hơn). One solution would be to chmod the folder to avoid external meddling of one's curious eyes. Một trong những giải pháp sẽ được để chmod các thư mục để tránh meddling mắt tò mò bên ngoài của một người. But working with Apache's features I found out that it is more convenient to use the mod_rewrite feature to deny access to a folder and its content. Nhưng làm việc với các tính năng của Apache tôi phát hiện ra rằng đó là thuận tiện hơn để sử dụng tính năng mod_rewrite để từ chối truy cập vào một thư mục và nội dung của nó. Here's the solution. Đây là giải pháp. In my case the folder I was trying to protect was templates so my code looked as following (simplified): Trong trường hợp của tôi trong thư mục tôi đã cố gắng để bảo vệ được các mẫu mã của tôi để xem xét như sau (đơn giản):
Options +FollowSymLinks
RewriteEngine on
#replace the word templates with the name of your own folder
RewriteRule ^/?templates/?(.*)?$ - [F,L]
Related posts: Liên quan đến bài viết:












































