简体   繁体   中英

PHP HipHop + rewrite to 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?

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;
}

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 .

我不熟悉HipHop,但是Apache上的.htaccess可以使用RewriteRule来解决这个问题

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM