PHP HipHop +重写到index.php
I wasted many hours to find, how to redirect all requests to index.php.
I mean: site.com/some-url?param&1
will become
site.com/index.php and $_SERVER[REQUEST_URI] === some-url?param&1
I've one hip hop archive (based on Nette Framework) and one virtualhost (one hiphop isntance proxied from Nginx).
Edit: Alternative question can be: how to setup nginx to modify REQUEST_URI field sent to PHP over FastCGI?
You have to add a rewrite rule to the main config.hdf file. hhvm does not support reading .htaccess files.
# In my app I have a public side and and admin
# side. All requests to the public side should
# be rerouted through a script. All requests to
# the backend .php and static asset files should
# be allowed.
* {
# rewrite every request onto
# /myapp/page.php/<original request>
pattern = ^(.*)$
to = /myapp/page.php/$1
# append any query strings.
qsa = true
}
I wrote an article about configuring hhvm.
I'm not familiar with HipHop but .htaccess on Apache can take care of this with RewriteRule
s
If you use Nginx in front of HHVM then you probably want the static files to be served by Nginx (because it's faster) and everything else pass to index.php
. In your Nginx site configuration you can do that as follows:
location / {
try_files $uri $uri/ index.php?$args;
}