Hide Index.php in CodeIgniter URI
Nginx中配置,去掉CodeIgniter URI中的index.php。参考了人家的文章和自己实践,得出配置如下(Nginx-1.2.0中通过):
location /php/ { # "/php" is the location of CodeIgniter
# Hide index.php in URI
rewrite ^(/php)/(?!index\.php|robots\.txt|images|js|style|fckeditor|upload)(.*)$ $1/index.php/$2 last;
}
把以上配置内容添加到Nginx的配置文件nginx.conf即可。
再看看这段配置,其实就是用URI跳转来实现,而且是用正则表达式匹配和替换。感觉很优美~