如何使用HHVM proxygen重写规则忽略任何文件? [英] How ignore any files using HHVM proxygen rewrite rules?

查看:104
本文介绍了如何使用HHVM proxygen重写规则忽略任何文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建这样的文件example.ini:

hhvm.server.type = proxygen

hhvm.server.default_document = index.php

hhvm.virtual_host[default][rewrite_rules][common][pattern] = "(.*)"
hhvm.virtual_host[default][rewrite_rules][common][to] = "index.php/$1"
hhvm.virtual_host[default][rewrite_rules][common][qsa] = true

并在终端中拨打电话:

$ hhvm -m server -p 9000 -d hhvm.server.source_root=/home/user/project -c example.ini

一切正常,但是我仍然可以浏览与项目位于同一文件夹中的现有文件,但是我希望将所有请求发送到"index.php" ,我该怎么办?

It's work fine, However I can still browse existing files that are in the same folder as the project, but what I would like is that all requests should be sent to "index.php", how can I do this?

推荐答案

如果您希望所有请求的100%通过重写规则,则添加以下内容:

If you want 100% of all request to go through the rewrite rules add this:

hhvm.virtual_host[default][check_existence_before_rewrite]= false

但是,除非您要构建API或具有100%动态内容的内容,否则请避免这种情况.应该允许提供静态内容,例如文本,html文件,图像等,而无需在您的PHP代码中进行评估.

However, unless you're building an API or something with 100% dynamic content, avoid this. Static content like text, html files, images, etc... should be allowed to be served up without having to be evaluated in your PHP code.

我建议将所有敏感文件和代码(index.php除外)保留在您的Web根目录之外.仅将静态文件放入该文件夹中,当然也要放入index.php,不要在此处放入其他代码.

I'd recommend keeping all sensitive files and code (except your index.php) outside your web root. Only put static files like in this folder and of course your index.php, don't put other code in here.

这篇关于如何使用HHVM proxygen重写规则忽略任何文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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