4

我有一个 CodeIgniter 项目,需要重写规则来导航控制器/视图等。我已经在 Ubuntu 12.04 上正确安装了 hiphop-php,并且它运行良好,包括他们网站上提供的示例 WordPress 安装和重写规则。

但是,我需要找出适用于 CodeIgniter index.php/controller 设置的正确重写规则,而我自己的运气并不好。

这是一个用于 WP 重写的示例 hiphop-php 配置文件:

http://www.hiphop-php.com/wp/

VirtualHost {
  * {
    Pattern = .*
    RewriteRules {
      dirindex {
        pattern = ^/(.*)/$
        to = $1/index.php
        qsa = true
      }
    }
  }
}

StaticFile {
  FilesMatch {
    * {
      pattern = .*\.(dll|exe)
      headers {
        * = Content-Disposition: attachment
      }
    }
  }

这是 Apache 的示例 CodeIgniter mod_rewrite 文件:

http://www.farinspace.com/codeigniter-htaccess-file/

<IfModule mod_rewrite.c>

    RewriteEngine On
    RewriteBase /

    ### Canonicalize codeigniter URLs

    # If your default controller is something other than
    # "welcome" you should probably change this
    RewriteRule ^(welcome(/index)?|index(\.php)?)/?$ / [L,R=301]
    RewriteRule ^(.*)/index/?$ $1 [L,R=301]

    # Removes trailing slashes (prevents SEO duplicate content issues)
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.+)/$ $1 [L,R=301]

    ###

    # Removes access to the system folder by users.
    # Additionally this will allow you to create a System.php controller,
    # previously this would not have been possible.
    # 'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php/$1 [L]

    # Checks to see if the user is attempting to access a valid file,
    # such as an image or css document, if this isn't true it sends the
    # request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]

</IfModule>

基本上,我需要重写的只是使用 CodeIgniter 的 index.php 控制器正确路由请求,这似乎是 apache 重写规则的最后一部分所做的。其余的我可以在看到一些例子后一起破解。

非常感谢!

4

3 回答 3

4

通常情况下,我通过自学找到了这一点,并从上面的 Trip 的回答中朝着正确的方向推进。我写了如何使用 nginx 作为代理以及如何通过 nginx 推送 PHP 请求。

http://www.kyleboddy.com/2013/05/02/facebooks-hiphop-engine-when-to-use-it-and-getting-it-to-work-with-codeigniter/

于 2013-05-02T22:32:04.513 回答
3

我没有足够的声誉对 SO 发表评论,但是......

https://github.com/facebook/hiphop-php/blob/master/hphp/doc/options.compiled

看起来没有办法在 HHPHP 配置中复制 -d 或 -f 标志,但选项的文档并不完全完整。如果可能的话,它必须看起来像这样:

    * {
      pattern = ^(.*)$
      to = /path/to/codeigniter/index.php/$1
      qsa = true
      conditions {
        -d {
          pattern = %{REQUEST_FILENAME}
          type = request
          negate = true
        }
        -f {
          pattern = %{REQUEST_FILENAME}
          type = request
          negate = true
        }
      }
    }

你有没有尝试过这些方面的任何事情?编辑:也许用 %{REQUEST_FILENAME} 块交换 -d 和 -f 文件标志。我可以把它倒过来。同样,文档不是很有启发性,我只是在吐痰。

于 2013-04-30T06:29:04.150 回答
1

使用 NGINX 作为 hiphop php 的前端。作为一个加号,您可以获得更好的静态文件服务性能。

于 2013-05-02T18:01:15.040 回答