Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How use [rewrite_rules][conditions] with REQUEST_FILENAME in .ini? #7816

Open
brcontainer opened this issue Apr 29, 2017 · 3 comments
Open

Comments

@brcontainer
Copy link

brcontainer commented Apr 29, 2017

HHVM Version

3.18.1

Standalone code, or other way to reproduce the problem

I expected to ignore only files, the folders would still go through rewrite (note that the ini is "commented"):

hhvm.virtual_host[default][check_existence_before_rewrite] = false

;hhvm.virtual_host[default][rewrite_rules][common][conditions][-d][pattern] = "%{REQUEST_FILENAME}"
;hhvm.virtual_host[default][rewrite_rules][common][conditions][-d][type] = request
;hhvm.virtual_host[default][rewrite_rules][common][conditions][-d][negate] = true

hhvm.virtual_host[default][rewrite_rules][common][conditions][-f][pattern] = "%{REQUEST_FILENAME}"
hhvm.virtual_host[default][rewrite_rules][common][conditions][-f][type] = request
hhvm.virtual_host[default][rewrite_rules][common][conditions][-f][negate] = true

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

This is an "illustrative" code, I believe that -d and -f flags aren't supported.

Expected result

Ignore rewrite_rules from form pattern


I reviewed the documentation, but only found the "check_existence_before_rewrite", Is there any way to check for the existence of specific files using proxygen before applying rewrite?

@mofarrell
Copy link
Contributor

According to the docs site:

    RewriteRules {
      * {
        pattern = regex pattern same as Apache's
        to = target format same as Apache's
        qsa = false
        redirect = 0 (default: off) | 302 | 301 | other status code

        conditions {
          * {
            pattern = regex pattern to match
            type = host | request
            negate = false
          }
        }
      }
    }

The position you are putting the flag in is a glob. The name you assign does not get used. The whole point is to allow for a vector of conditions. In this case you are just labeling the entries in the vector as -d, and -f.

There is not support for those flags.

@brcontainer
Copy link
Author

@mofarrell it's pseudo-code, is only a example :)

I would just like to know if there is any way to check the file exists within [conditions].

@mofarrell
Copy link
Contributor

Not currently. The only option available for related to that is the global one.
Adding logic to support that shouldn't be too hard. The rewrite system is pretty self contained.
https://github.com/facebook/hhvm/blob/master/hphp/runtime/server/virtual-host.cpp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants