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 Uppdateringar via RSS | E-post Get updates via feedburner Get updates via twitter
Home / Apache & mod_rewrite / Coding / Apache & ModRewrite: How… Hem / Apache och mod_rewrite / Kodning / Apache & ModRewrite: How ...

Apache & ModRewrite: How to easily deny access to a folder with htaccess Apache & ModRewrite: Så enkelt neka tillgång till en mapp med htaccess

Posted on 17. Posted on 17. Jul, 2009 by Dragos in Apache & mod_rewrite , Coding Juli, 2009 av Dragos i Apache och 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). Arbetar med ett projekt just nu jag letade efter en lösning för att skydda en mapp som innehåller mall php-filer (ingår i större filer). One solution would be to chmod the folder to avoid external meddling of one's curious eyes. En lösning skulle vara att chmod mapp att undvika yttre inblandning av ens nyfikna ögon. 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. Men att arbeta med Apaches funktioner jag fick veta att det är bekvämare att använda mod_rewrite funktionen att neka åtkomst till en mapp och dess innehåll. Here's the solution. Här är lösningen. In my case the folder I was trying to protect was templates so my code looked as following (simplified): I mitt fall mappen jag försökte skydda var mallar så min kod såg ut som följande (förenklat):


Options +FollowSymLinks
RewriteEngine on
#replace the word templates with the name of your own folder
RewriteRule ^/?templates/?(.*)?$ - [F,L]

Translate this post Översätta det här inlägget


Related posts: Relaterade tjänster:

  1. PHP: Get all files and folders from a directory (folder) PHP: Få alla filer och mappar från en katalog (mapp)

    blog comments powered by Disqus blogg kommentarer drivs av Disqus