<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                pathinfo模式是偽靜態的一種:`http://www.xxx.com/index.php/模塊/控制器/方法` pathinfo 模式 需要 php.ini 開啟下面這個參數 ``` cgi.fix_pathinfo=1 ``` apache服務器本身是支持pathinfo的,通過簡單修改幾項配置即可。當配置支持pathinfo后,在php應用程序中,通過\_SERVER\['PATH\_INFO'\]變量獲取pathinfo值為/topic/detail/tid/82.html。 我們就可以很容易通過php邏輯代碼來解析出controller文件、action方法、以及剩余的動態參數,進而就可以返回正確的網頁響應。 但是我們要說的**nginx服務器默認是不支持pathinfo模式訪問**。實質上就是nginx不會去設置環境變量PATH\_INFO 的值,導致php應用程序不能通過\_SERVER\['PAHT\_INFO'\]來獲取path\_info, 也就不能解析出對應的動態參數。 ## **nginx支持pathinfo的配置如下:** **1\. 找到ngingx的配置文件nginx.conf** 在server里的location項, **修改前為:** ~~~ location ~ \.php$ { #注:去掉本行的$ 字符 root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; #注:下面加上一些配置語句 } ~~~ **修改后為:** ~~~ location ~ \.php { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params;#這里可以新建一個文件include fcgi.conf;(fastcgi_paramsi.conf;??)專門保存fastcgi_param參數和值 #定義變量 $path_info ,用于存放pathinfo信息 set $path_info ""; #定義變量 $real_script_name,用于存放真實地址 set $real_script_name $fastcgi_script_name; #如果地址與引號內的正則表達式匹配 if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") { #將文件地址賦值給變量 $real_script_name set $real_script_name $1; #將文件地址后的參數賦值給變量 $path_info set $path_info $2; } #配置fastcgi的一些參數 fastcgi_param SCRIPT_NAME $real_script_name; fastcgi_param PATH_INFO $path_info; fastcgi_param GATEWAY_INTERFACE CGI/1.1; fastcgi_param SERVER_SOFTWARE nginx; fastcgi_param QUERY_STRING $query_string; fastcgi_param REQUEST_METHOD $request_method; fastcgi_param CONTENT_TYPE $content_type; fastcgi_param CONTENT_LENGTH $content_length; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_NAME $fastcgi_script_name; fastcgi_param REQUEST_URI $request_uri; fastcgi_param DOCUMENT_URI $document_uri; fastcgi_param DOCUMENT_ROOT $document_root; fastcgi_param SERVER_PROTOCOL $server_protocol; fastcgi_param REMOTE_ADDR $remote_addr; fastcgi_param REMOTE_PORT $remote_port; fastcgi_param SERVER_ADDR $server_addr; fastcgi_param SERVER_PORT $server_port; fastcgi_param SERVER_NAME $server_name; # PHP only, required if PHP was built with --enable-force-cgi-redirect fastcgi_param REDIRECT_STATUS 200; } ~~~ **2.重啟nginx和phpcgi** **其他參考:** thinkphp 框架比較好了支持了pathinfo模式訪問,可以去深入了解一下它是怎么支持pathinfo格式的。 ## **配置2參考** ``` 典型默認配置 location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $DOCUMENT_ROOT$fastcgi_script_name; include fastcgi_params; } 修改后的配置 修改第1,6行,支持pathinfo location ~ \.php(.*)$ { # 正則匹配.php后的pathinfo部分($是引用參數 數字是第1~n個參數) root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $DOCUMENT_ROOT$fastcgi_script_name; fastcgi_param PATH_INFO $1; # 把pathinfo部分賦給PATH_INFO變量 include fastcgi_params; } ``` ## **配置3參考** ~~~ 典型默認配置 location / { #訪問路徑,可相對也可絕對路徑 root html; #首頁文件。以下按順序匹配 index index.html index.htm; } 修改后的配置 location / { #訪問路徑,可相對也可絕對路徑 root html; #首頁文件。以下按順序匹配 index index.html index.htm; if (!-e $request_filename) { rewrite ^/index.php(.*)$ /index.php?s=$1 last; rewrite ^(.*)$ /index.php?s=$1 last; break; } } ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看