【问题标题】:PHP HipHop + rewrite to index.phpPHP HipHop + 重写为 index.php
【发布时间】:2013-10-09 12:45:34
【问题描述】:

我浪费了很多时间来寻找,如何将所有请求重定向到 index.php。

我的意思是: site.com/some-url?param&1

会变成

site.com/index.php 和 $_SERVER[REQUEST_URI] === some-url?param&1

我有一个 hip hop 存档(基于 Nette 框架)和一个虚拟主机(一个从 Nginx 代理的 hiphop 实例)。

编辑: 替代问题可以是:如何设置 nginx 以修改通过 FastCGI 发送到 PHP 的 REQUEST_URI 字段?

【问题讨论】:

    标签: php hhvm


    【解决方案1】:

    您必须在主 config.hdf 文件中添加重写规则。 hhvm 不支持读取 .htaccess 文件。

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

    我写了an article about configuring hhvm

    【讨论】:

      【解决方案2】:

      如果您在 HHVM 之前使用 Nginx,那么您可能希望静态文件由 Nginx 提供(因为它更快),其他所有内容都传递给 index.php。在您的 Nginx 站点配置中,您可以执行以下操作:

      location / {
          try_files $uri $uri/ index.php?$args;
      }
      

      【讨论】:

        【解决方案3】:

        我不熟悉 HipHop,但 Apache 上的 .htaccess 可以通过 RewriteRules 解决这个问题

        【讨论】:

        • 没有 .htaccess,因为源代码在编译存档中。我在 nginx 上运行。但是thnaks :)
        猜你喜欢
        • 2022-08-19
        • 1970-01-01
        • 1970-01-01
        • 2013-06-25
        • 2011-06-10
        • 2018-08-27
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多