.htaccess 异常(图像损坏)
我正在使用:
RewriteRule ^(.*)$ index.php?abrir=$1
RewriteRule ^(.*)/(.*)/(.*)$ index.php?abrir=$1&id=$2&pagina=$3
并且我有图像链接:
/data_livro/capa_livro/af58e898f91509b.jpg
如何添加显示图像的例外?它坏了......
我的完整.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'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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果我理解正确,在 RewriteRules 之前添加以下内容应该可以解决问题:
但是,我还建议将 RewriteRules 修改为如下所示:
If I'm understanding this correctly, ading the following ahead of your RewriteRules should solve the problem:
However, I'd also suggest modifying your RewriteRules to look like:
我发现在重写规则中使用
.*
太笼统了。我倾向于使用更具体的字符类:这不会重写任何带有点的请求,因此特定的文件名(/styles/my.css、/images/example.jpg)会被忽略。另外,我喜欢添加
/?
以允许可选的尾部斜杠,但这是个人偏好:-)。I find that using
.*
in a rewrite rule is too general. I tend to use more specific character classes: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 :-).