前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >nginx伪静态规则配置

nginx伪静态规则配置

作者头像
Sindsun
发布2018-06-21 17:31:26
7.4K0
发布2018-06-21 17:31:26
举报
文章被收录于专栏:狂码一生

服务器配置文件:

代码语言:javascript
复制
server{
        listen       80;
        server_name  www.abc.com;
        root   "D:/phpStudy/WWW/abc";
        location / {
            index  index.php index.htm /public/index.html;
            autoindex  off;
            include abc.conf;
            #rewrite a.html /index.php/front/index/index last;
        }
        location ~ \.php(.*)$  {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_param  PATH_INFO  $fastcgi_path_info;
            fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
            include        fastcgi_params;
        }
    }

伪静态配置文件可以直接写在 location / {} 里面的,不推荐这样做,建议新增加个rewrite.conf写伪静态文件会好点,include 进来就行了,这样可以在rewrite.conf里面写n多配置

代码语言:javascript
复制
location / {            index  index.php index.htm /public/index.html;
            autoindex  off;
            include rewrite.conf;            #rewrite a.html /index.php/front/index/index last;
        }

rewrite.conf (这个文件自己创建就行了,文件内容写规则)

代码语言:javascript
复制
#场景一的规则
    #http://www.abc.com/index.php/front/index/indexrewrite a.html /index.php/front/index/index last;
#场景二的规则
    #1.http://www.abc.com/index.php/front/index/parse/name/yangxignyi/age/18
    #2.http://www.abc.com/index.php/front/index/parse?name=yangxignyi&age=18
    #3.http://www.abc.com/parse-yangxingyi-18.htmlrewrite parse-(\w+)-(\d+).html /index.php/front/index/parse/name/$1/age/$2 last;

最后,重启nginx!

.pwarm{ text-indent:0px !important; padding: 5px !important; } .pwarm p,a,span{ text-indent:0px !important; word-break: break-all; }

版权声明: 此文为本站源创文章[或由本站编辑从网络整理改编], 转载请备注出处: [ 狂码一生 ] http://www.sindsun.com/article-details-73.html [若此文确切存在侵权,请联系本站管理员进行删除!]

window._bd_share_config = { "common": { "bdSnsKey": {}, "bdText": "", "bdMini": "2", "bdMiniList": false, "bdPic": "", "bdStyle": "1", "bdSize": "32" }, "share": {} }; with(document) 0[(getElementsByTagName('head')[0] || body).appendChild(createElement('script')).src = 'http://bdimg.share.baidu.com/static/api/js/share.js?v=0.js?cdnversion=' + ~ ( - new Date() / 36e5)];

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2018-05-16,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档