• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP的Symfony和CodeIgniter框架的Nginx重写规则配置

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

Symfony
Symfony国外很流行的php框架,目前国内用的相对较少,但是一定会在国内火起来. nginx重写规则如下

server {
 server_name ogeek.net www.ogeek.net;
 root /data/site/www.ogeek.net;
location / {
 # try to serve file directly, fallback to rewrite
 try_files $uri @rewriteapp;
 }
location @rewriteapp {
 # rewrite all to app.php
 rewrite ^(.*)$ /app.php/$1 last;
 }
location ~ ^/(app|app_dev|config).php(/|$) {
 fastcgi_pass unix:/var/run/php5-fpm.sock; # 改成你对应的FastCGI
 fastcgi_split_path_info ^(.+.php)(/.*)$;
 include fastcgi_params;
 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
 fastcgi_param HTTPS off;
 }
error_log /data/logs/nginx/www.ogeek.net_error.log;
 }

 
重启nginx即可

CodeIgniter
CodeIgniter,即被很多人简称为CI的高人气PHP框架,其中文社区也比较活跃,来看一下CI的rewrite写法:

server {
 listen 80;
 server_name ogeek.net www.ogeek.net;
root /data/site/www.ogeek.net;
 index index.php;
 error_log log/error.log;
# set expiration of assets to MAX for caching
 location ~* .(ico|css|js|gif|jpe?g|png)(?[0-9]+)?$ {
 expires max;
 log_not_found off;
 }
# main codeigniter rewrite rule
 location / {
 try_files $uri $uri/ /index.php;
 }
# php parsing
 location ~ .php$ {
 root /data/site/ogeek.net/;
 try_files $uri =404;
 fastcgi_pass unix:/tmp/php5-fpm.sock; # 改成对应的FastCGI
 fastcgi_index index.php;
 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
 include fastcgi_params;
 fastcgi_buffer_size 128k;
 fastcgi_buffers 256 4k;
 fastcgi_busy_buffers_size 256k;
 fastcgi_temp_file_write_size 256k;
 }
}


修改CI(CodeIgniter )配置文件config.php

$config['base_url'] = "https://www.ogeek.net/";
 $config['index_page'] = "";
 $config['uri_protocol'] = "REQUEST_URI";


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Nginx配置PHP的Yii与CakePHP框架的rewrite规则示例发布时间:2022-02-12
下一篇:
Nginx中配置用户服务器访问认证的方法示例发布时间:2022-02-12
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap