El archivo .htaccess no muestra imágenes

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

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 directory and I don't use http:// etc.


preguntado el 27 de agosto de 11 a las 20:08

What shows in the browser when you hit the URL? -

What exactly happens and what URLs are you using? -

Trata <FilesMatch> with a regex as the manual recommends. Alternatively a RewriteRule con [F] param. Cause might be that the Deny rule applies directory-wise. So sayeth the manual. -

This is very unclear and it's impossible to tell why this might be affecting other directories. You need to show some example URLs at least. -

Thanks @mario that seemed to solve the problem. Mind posting this as an answer? -

1 Respuestas

Al 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.

Respondido 28 ago 11, 04:08

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.