我有一个CodeIgniter项目,需要重写规则来导航控制器/视图等。我已经在Ubuntu 12.04上正确安装了hiphop-php,它工作得很好,包括WordPress的安装示例和他们网站上提供的重写规则。
然而,我需要找出适当的重写规则,将与CodeIgniter index.php/控制器设置工作,我没有太多的运气自己。
下面是一个用于重写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重写规则的最后一部分做。剩下的我可以在看了一些例子后拼凑起来。
多谢了!
与一般情况一样,我通过自学和从上面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/我没有足够的声誉来发表评论,但是…
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
}
}
}
你试过这些方法吗?编辑:也许可以将-d和-f文件标志与%{REQUEST_FILENAME}部分交换。我可以把它反过来。同样,文档不是很有启发性,我只是随便说说。
使用NGINX作为hiphop php的前端。作为一个加分项,您将获得更好的性能为静态文件服务