I have a CodeIgniter project that requires rewriting rules to navigate controllers/views and the like. I have correctly installed hiphop-php on Ubuntu 12.04 and it works perfectly, including with the sample WordPress installation and rewrite rules provided on their site.
我有一个CodeIgniter项目,需要重写规则来导航控制器/视图等。我已经在Ubuntu 12.04上正确安装了hiphop-php,它运行良好,包括在他们的网站上提供的示例WordPress安装和重写规则。
However, I need to figure out the proper rewrite rules that will work with the CodeIgniter index.php/controller setup and I haven't had much luck myself.
但是,我需要找出适用于CodeIgniter index.php / controller设置的正确重写规则,我自己也没有多少运气。
Here is a sample hiphop-php config file for WP rewriting:
这是一个用于WP重写的示例hiphop-php配置文件:
VirtualHost {
* {
Pattern = .*
RewriteRules {
dirindex {
pattern = ^/(.*)/$
to = $1/index.php
qsa = true
}
}
}
}
StaticFile {
FilesMatch {
* {
pattern = .*\.(dll|exe)
headers {
* = Content-Disposition: attachment
}
}
}
And here's a sample CodeIgniter mod_rewrite file for Apache:
这是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>
Basically all I need the rewriting to do is route the requests properly with the index.php controller of CodeIgniter, which seems to be what the last part of the apache rewrite rules do. The rest I can hack together after seeing some examples.
基本上我需要重写的是使用CodeIgniter的index.php控制器正确地路由请求,这似乎是apache重写规则的最后一部分。其余的我可以在看到一些例子后一起破解。
Thanks a bunch!
谢谢你!
3 个解决方案
#1
4
As is generally the case, I figured this one out via self-study and some pushing in the right direction from Trip's answer above. I wrote up how to use nginx as a proxy and how to push PHP requests through nginx.
通常情况下,我通过自学来解决这个问题,并且有些人从Trip的答案中推进了正确的方向。我写了如何使用nginx作为代理以及如何通过nginx推送PHP请求。
#2
3
I don't have enough reputation to post a comment on SO, but...
我没有足够的声誉对SO发表评论,但......
https://github.com/facebook/hiphop-php/blob/master/hphp/doc/options.compiled
It doesn't look like there's a way to duplicate the -d or -f flags in the HHPHP config, but the documentation of the options isn't exactly thorough. If it's possible, it has to look something like this:
看起来没有办法在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
}
}
}
Have you tried anything along these lines? EDIT: Maybe swap the -d and -f file flags with the %{REQUEST_FILENAME} piece. I could have that backwards. Again, the documentation isn't very illuminative, and I'm just spit-balling.
你沿着这些方向尝试了什么吗?编辑:也许用%{REQUEST_FILENAME}块交换-d和-f文件标志。我可以倒退了。再次,文档不是很有启发性,我只是吐痰。
#3
1
Use NGINX as frontend for hiphop php. As a plus You are get better performance for serve static files.
使用NGINX作为hiphop php的前端。作为一个优点,您可以获得更好的服务静态文件性能。
#1
4
As is generally the case, I figured this one out via self-study and some pushing in the right direction from Trip's answer above. I wrote up how to use nginx as a proxy and how to push PHP requests through nginx.
通常情况下,我通过自学来解决这个问题,并且有些人从Trip的答案中推进了正确的方向。我写了如何使用nginx作为代理以及如何通过nginx推送PHP请求。
#2
3
I don't have enough reputation to post a comment on SO, but...
我没有足够的声誉对SO发表评论,但......
https://github.com/facebook/hiphop-php/blob/master/hphp/doc/options.compiled
It doesn't look like there's a way to duplicate the -d or -f flags in the HHPHP config, but the documentation of the options isn't exactly thorough. If it's possible, it has to look something like this:
看起来没有办法在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
}
}
}
Have you tried anything along these lines? EDIT: Maybe swap the -d and -f file flags with the %{REQUEST_FILENAME} piece. I could have that backwards. Again, the documentation isn't very illuminative, and I'm just spit-balling.
你沿着这些方向尝试了什么吗?编辑:也许用%{REQUEST_FILENAME}块交换-d和-f文件标志。我可以倒退了。再次,文档不是很有启发性,我只是吐痰。
#3
1
Use NGINX as frontend for hiphop php. As a plus You are get better performance for serve static files.
使用NGINX作为hiphop php的前端。作为一个优点,您可以获得更好的服务静态文件性能。