/mapname
/mapname/file1
RewriteCond %{REQUEST_URI} /mapname
RewriteRule ^.*$ / [R=301,L]
欢迎各位兄弟 发布技术文章
这里的技术是共享的
| |||
| |||||
|
|
100 33 | Here is the scenario:
I want to restrict direct user access to the files in |
100 33 | Here is the scenario:
I want to restrict direct user access to the files in | |||
209 | I would just move the
That way you cannot open any file from that folder, but you can include them in php without any problems. | ||||||||||||||||||||
|
40 | This is pure
This will show forbidden error to use if URI contains either | ||||
|
13 | It's possible to use a Files directive and disallow access to all files, then use it again to set the files that are accessible:
| ||||||||
|
8 | If I understand correctly you just want to deny access to the includes folder? An .htaccess with a 'DENY FROM ALL' directive placed in the includes folder would do the trick. | ||
8 | Your Q comes in two parts, both jeroen and anubhava's solutions work for part I -- denying access to /includes. anubhava's also works for part II. I prefer the latter because I use a However what I wanted t discuss is the concept of "denying access to If this is true then you can't use anubhava's part II as this will cause your form to fail. What you can do here is (i) with the
And (ii) within your PHP index.php form generator include some hidden fields for a timestamp and validation. The validation could be, say, the first 10 chars of an MD5 of the timestamp and some internal secret. On processing the submit you can then (i) validate that the timestamp and validation match, and (ii) the timestamp is within, say, 15 minutes of the current time. This you can prevent spamming as the only practical way that a spammer could get a valid timestamp / validation pair would be to parse a form, but this scrape would only have a 15 minute life. | ||
8 | 1 liner mod_alias based solution :
This will show forbidden error for /folder/file.php | ||||
|
4 | Depending on possible other options set at a higher level you may need to put the following in your .htaccess file in your includes directory:
I ran into this when the upper directory defined basic authentication including the line:
This was preventing my deny from all to take effect because the users were authenticated. | ||