欧美一区2区三区4区公司二百,国产精品婷婷午夜在线观看,自拍偷拍亚洲精品,国产美女诱惑一区二区

歡迎來到云服務(wù)器

服務(wù)器租用

Nginx 下 ThinkPHP URL 的 PATHINFO 與 REWRITE

Nginx 開啟 PATHINFO

在這之前, 筆者也到搜索引擎上看了幾篇關(guān)于 Nginx 設(shè)置 PATHINFO 的要領(lǐng), 感受有點亂, 亂的原因主要是由于 Nginx 沒有給以像 Apache 那樣一個參數(shù)即可開啟 PATHINFO 的精采支持, 因此呈現(xiàn)了各類 Nginx 下開啟 PATHINFO 的解法。

這里提供的是參閱 Nginx 官方文檔并團結(jié)實測可用后的 PATHINFO 的方案。去除不必需的注釋, Nginx 開啟 PATHINFO 的 server 部門設(shè)置如下:

server {
    listen       80;
    server_name  localhost;
    location / {
        root   D:/Projects/Demo/thinkphp;   # 你的 TP 框架 index.php 地址目次, 記得用 / 支解路徑
        index index.php index.html index.htm;
    }
    # ...
    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ ^(.+.php)(.*)$ {
        root   D:/Projects/Demo/thinkphp;   # 你的 TP 框架 index.php 地址目次, 記得用 / 支解路徑
        fastcgi_split_path_info ^(.+.php)(.*)$;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
}

這種做法的道理是當請求的會見路徑中含有 .php 時, 通過正則表達式結(jié)構(gòu)出 PATHINFO, 并配置到 fastcgi 的參數(shù) PATH_INFO 中。

代碼中匹配 PATH_INFO 的正則表達式來歷于 Nginx 官方文檔中的寫法。拜見: http://nginx.org/en/docs/http/ngx_http_fastcgi_module.html#fastcgi_split_path_info

PATHINFO 模式是 ThinkPHP 默認的 URL 模式, 因此不需要修改 ThinkPHP 的默認設(shè)置即可利用 http://serverName/index.php/模塊/節(jié)制器/操縱 方法會見。


URL REWRITE 模式

REWRITE 模式也稱 URL重寫, 可用于埋沒 PATHINFO 模式路徑中的 index.php, 開啟 REWRITE 模式的 Nginx 設(shè)置為:

server {
    listen       80;
    server_name  localhost;
    location / {
        root   D:/Projects/Demo/thinkphp;   # 你的 TP 框架 index.php 地址目次, 記得用 / 支解路徑
        index index.php index.html index.htm;
        try_files $uri $uri/ /index.php?s=$uri; # 焦點
    }
    # ...
    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ .php$ {
        root   D:/Projects/Demo/thinkphp;   # 你的 TP 框架 index.php 地址目次, 記得用 / 支解路徑
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
}

設(shè)置完成后修改 ThinkPHP 的 URL 模式為 REWRITE, 編輯設(shè)置文件 ThinkPHP/Conf/convention.php 中修改 URL_MODEL 參數(shù)值為 2 (REWRITE 模式)即可通過 http://serverName/模塊/節(jié)制器/操縱 方法會見。

騰訊云代理

Copyright © 2003-2021 MFISP.COM. 國外vps服務(wù)器租用 夢飛云服務(wù)器租用 版權(quán)所有 ? 粵ICP備11019662號

主站蜘蛛池模板: 中江县| 临邑县| 芮城县| 通河县| 龙州县| 石狮市| 象山县| 德兴市| 桐城市| 东光县| 永昌县| 五常市| 偃师市| 东城区| 阿克陶县| 盈江县| 禹州市| 凭祥市| 右玉县| 利辛县| 曲靖市| 霍城县| 广宗县| 鸡西市| 芦溪县| 靖宇县| 邹平县| 鄂托克旗| 禹州市| 乾安县| 彝良县| 洛扎县| 麟游县| 泸州市| 兰溪市| 拉萨市| 西充县| 邵武市| 玉树县| 鹤岗市| 封开县|