异常的.htaccess(图像破碎) [英] Exception with .htaccess (image broken)
问题描述
我使用的是:
重写规则^(。*)$的index.php?abrir = $ 1
重写规则^ / / $的index.php abrir = $ 1安培(*)(*)(*);?ID = $ 2及pagina = $ 3
和我有图片链接:
/data_livro/capa_livro/af58e898f91509b.jpg
如何,我可以添加一个例外显示图像?它打破了......
我的完整的.htaccess:
RewriteEngine叙述上
的RewriteCond%{} REQUEST_FILENAME!-f
重写规则^([^ /] +)$的index.php?abrir = $ 1
重写规则^([^ /] +)/([^ /] +)/([^ /] +)$的index.php abrir = $ 1安培;?ID = $ 2及pagina = $ 3
重写规则\。(JPG | JPEG | PNG | GIF)$ - [NC,F,L]
的ErrorDocument 400的index.php
的ErrorDocument 401的index.php
的ErrorDocument 403的index.php
的ErrorDocument 404的index.php
的ErrorDocument 504的index.php
的ErrorDocument 505的index.php
的DirectoryIndex index.php文件
我发现,使用。*
在重写规则过于笼统。我更倾向于使用特定的字符类:
重写规则^([A-ZA-Z0-9 _-] +)/ $的index.php?abrir = $ 1
重写规则^(〔一个 - 杂 - Z0-9 _-] +)/([一 - 杂 - Z0-9 _-] +)/([一 - 杂 - Z0-9 _-] +)/?$的index.php? abrir = $ 1安培; ID = $ 2及pagina = $ 3
这不重写,在这一个点被忽略的任何要求,因此具体的文件名(/styles/my.css,/images/example.jpg)。 ?另外,我想补充 /
允许可选尾随斜线,但这是一个个人的preference: - )
I'm using:
RewriteRule ^(.*)$ index.php?abrir=$1
RewriteRule ^(.*)/(.*)/(.*)$ index.php?abrir=$1&id=$2&pagina=$3
and I have the image link:
/data_livro/capa_livro/af58e898f91509b.jpg
How I can add a exception for show the image? Its broke...
My full .htaccess:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)$ index.php?abrir=$1
RewriteRule ^([^/]+)/([^/]+)/([^/]+)$ index.php?abrir=$1&id=$2&pagina=$3
RewriteRule \.(jpg|jpeg|png|gif)$ - [NC,F,L]
ErrorDocument 400 index.php
ErrorDocument 401 index.php
ErrorDocument 403 index.php
ErrorDocument 404 index.php
ErrorDocument 504 index.php
ErrorDocument 505 index.php
DirectoryIndex index.php
I find that using .*
in a rewrite rule is too general. I tend to use more specific character classes:
RewriteRule ^([a-zA-Z0-9_-]+)/?$ index.php?abrir=$1
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/?$ index.php?abrir=$1&id=$2&pagina=$3
This doesn't rewrite any request with a dot in it, so specific file names (/styles/my.css, /images/example.jpg) get ignored. Also, I like to add /?
to allow an optional trailing slash, but that's a personal preference :-).
这篇关于异常的.htaccess(图像破碎)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!