Forum Moderators: phranque

Message Too Old, No Replies

Allowing access to one file, but denying access to rest of folder

         

TheBaker

10:50 am on Jul 14, 2004 (gmt 0)

10+ Year Member



Does anyone know what I'd have to put in a .htaccess file so that I could allow visitors to view index.php in a folder, but deny them access to all the other files in the folder.

Thanks in advance

gergoe

11:16 am on Jul 14, 2004 (gmt 0)

10+ Year Member



See the mod_rewrite documentation [httpd.apache.org] on how to accomplish on this.

One of the possible solutions is to use a RewriteRule [httpd.apache.org] with no substitution string and specifying the Forbidden flag with the combination of a RewriteCond [httpd.apache.org] which should evaluate true only if the requested page is not the index.php file (which you can achieve by preceding the regex pattern with an exclamation mark).

TheBaker

11:46 am on Jul 14, 2004 (gmt 0)

10+ Year Member



Aggh! You've lost me already! And that documentation made my head hurt :( I'm new to this htaccess stuff, so how about some examples or something?

jdMorgan

2:45 pm on Jul 14, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



TheBaker,

Welcome to WebmasterWorld [webmasterworld.com]!

Using mod_rewrite in .htaccess:


RewriteRule !^index\.php$ - [F]

Apache mod_rewrite documentation [httpd.apache.org]
Apache URL Rewriting Guide [httpd.apache.org]
Regular Expressions Tutorial [etext.lib.virginia.edu]

Jim