url.rewrite-once 与 Kohana 和 urls
目前我在 simple-hosts.conf 中有这样的设置:
url.rewrite-once = (
".*.(js|ico|gif|jpg|png|css|php|htm)(?.*)?$" => "$0",
"/slapi" => "/slapi/index.php"
)
效果很好,但当我在查询字符串中有一个点时,上面的方法会失败:
?url=http://google.com
Currently I have this setup in our simple-hosts.conf:
url.rewrite-once = (
".*.(js|ico|gif|jpg|png|css|php|htm)(?.*)?$" => "$0",
"/slapi" => "/slapi/index.php"
)
Works great, except the above fails when I have a dot in the query string:
?url=http://google.com
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为什么不直接使用
server.error-handler-404 = "/path/to/index.php"
?但至于正则表达式本身,其中有许多未转义的字符。第二个
.
我假设您的意思是文字.
。如果是这样,您需要使用反斜杠\.
对其进行转义。同样的情况也适用于?字符(我再次假设您的意思是字面意思?)。所以正则表达式应该是:另外,您可以通过删除查询模式周围的问号来进一步改进它(我更喜欢这种语法,我发现它更容易阅读):
Why not just use the
server.error-handler-404 = "/path/to/index.php"
?But as for the regex itself, you have many unescaped characters in there. The second
.
I'm assuming you mean as a literal.
. If so, you need to escape it with a backslash\.
. The same goes with the ? character (which again, I'm assuming you mean a literal ?). So the regex should be:Plus, you could improve it even more by removing the question mark around the query pattern (I prefer this syntax, I find it easier to read):