This is a translated page. The original can be found here: http://iwebdevel.com/2009/07/17/apache-modrewrite-how-to-easily-deny-access-to-a-folder-with-htaccess/
UPDATES VIA RSS | Email CẬP NHẬT VIA RSS | Email Get updates via feedburner Get updates via twitter
Home / Apache & mod_rewrite / Coding / Apache & ModRewrite: How… Trang chủ / Apache & mod_rewrite / Coding / Apache & ModRewrite: Làm thế nào ...

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]

Translate this post Dịch bài đăng này


Related posts: Liên quan đến bài viết:

  1. PHP: Get all files and folders from a directory (folder) PHP: Nhận tất cả các file và thư mục từ một thư mục (folder)

    blog comments powered by Disqus blog ý kiến được hỗ trợ bởi are On