How ignore any files using HHVM proxygen rewrite r

2019-07-09 09:59发布

问题:

I create a file like this 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

And calling in terminal:

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

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?

回答1:

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

hhvm.virtual_host[default][check_existence_before_rewrite]= false

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.

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.