的.htaccess排除目录要rewrited [英] .htaccess exclude a directory to be rewrited

查看:314
本文介绍了的.htaccess排除目录要rewrited的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在这里我错了,在这个htaccess的,因为/资产/文件夹不排除重写规则。 当我访问: http://www.site.com/assets/images /sidebar1/some/pic.pngs 不返回404如我所料。

where I'm wrong in this htaccess, because /assets/ folder isn't excluded from rewrite rule. When I access: http://www.site.com/assets/images/sidebar1/some/pic.pngs isn't return 404 as I expected.

Options -Indexes
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_URI} !^/?(assets|css)/
RewriteRule . index.php

感谢

推荐答案

您的规则说:

改写一切的index.php时:

rewrite everything to index.php when :

该URL不是一个文件,而不是一个目录,而不是在 /资产/ / CSS /

The URL is not a file and is not a directory and is not in /assets/ or /css/.

你问的文件不是一个文件,而不是一个目录,并在资产/

The file you're asking is not a file, not a directory and is in assets/:

这样就OK了规则,但是!您的日志显示,那么你所要求的 /home/valentin/public_html/404.shtml (自动重定向不明物体!)

So ok for the rule, BUT! your log show you are then asking for /home/valentin/public_html/404.shtml (automatic redirection for the unknown object!)

和这个请求通过的规则了!

And this request goes through the rules again!

这是不是一个文件(!-f匹配),而不是一个目录(!-d匹配),它是不是在资产/ 也不在 CSS / 然后它被改写到的index.php

It is not a file (!-f matched), not a directory (!-d matched) and it is not in assets/ nor in css/ then it gets rewritten to index.php

Q.E.D。

您可以通过将404.shtml在的public_html / 文件夹中解决这个问题,还是Apache的配置更改为一个真正的文件。

You can correct this by putting the 404.shtml in your public_html/ folder, or change this in apache configuration to a real file.

这篇关于的.htaccess排除目录要rewrited的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆