开发者

.htaccess file not showing pictures

I'm using a .htaccess file and im using the following code to try and revoke access from text files:

<Files *.txt>
order deny,allow
deny from all
</Files>

This does revoke access but not text files only. It also doesn't allow pictures to be shown on another page which is strange because the pictures aren't in the same di开发者_Go百科rectory and I don't use http:// etc.

BROWSER DISPLAYS FORBIDDEN PAGE WHAT ELSE WOULD IT SHOW?


The Deny rule applies directory-wise even if it's in a declaration block. <Files> will therefore often fail.

The manual mentions <FilesMatch> as the preferred alternative, and it often works with authorization statements. I wouldn't count on this however; I had trouble getting this to work with multiple sections and overrides.

A more advisable alternative is to use a RewriteRule:

 RewriteRule  .+\.txt$  -  [FORBIDDEN,LAST]

Which is also easier to restrict the effect to the current directory.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜