歡迎使用我的 在線工具

          小D

          讀歷史、看小說、寫程序都是我所愛。技術不好,頭腦不靈光,靠的是興趣。
          隨筆 - 35, 文章 - 25, 評論 - 13, 引用 - 0
          數據加載中……

          Linux下nginx配置codeigniter去掉index.php

          原先的系統url中多出一個index.php讓我不爽,靜態化優雅的url才好看,雖然是偽的,其實只需在nginx.conf中加入如下配置:
          server {
              listen 80;
              server_name yourservername;
              
              location / {
                 root /your/root/path/;
                 index index.php index.html index.htm;
                 if (-f $request_filename) {
                   expires max;
                   break;
                 }

                 #if (!-e $request_filename) {
                 #    rewrite ^/(.*)$ /index.php/$1 last;
                 #}
                  if ($request_filename !~ (js|css|images|robots/.txt|index/.php.*) ) {
                      rewrite ^/(.*)$ /index.php/$1 last;
                      break;
                  }

              }
              error_page   500 502 503 504  /50x.html;
              location = /50x.html {
                  root   /usr/share/nginx/html;
              }
              location ~ \.php($|/) {
                  root           /your/root/path;
                  fastcgi_pass   127.0.0.1:9000;
                  fastcgi_index index.php;
                  fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                  fastcgi_param  PATH_INFO  $fastcgi_path_info;
                  fastcgi_split_path_info ^(.+\.php)(.*)$;
                  include fastcgi_params;
              }

          }

          然后在codeigniter項目的application/config/config.php中的$config['index_page'] = '';即可。然后刷新頁面就可以了。

          posted on 2012-09-19 10:18 vagasnail 閱讀(2500) 評論(0)  編輯  收藏 所屬分類: 服務器

          主站蜘蛛池模板: 平塘县| 惠水县| 类乌齐县| 灯塔市| 嘉鱼县| 安阳县| 博客| 靖宇县| 陇西县| 兴安盟| 中江县| 大埔区| 丰城市| 洛阳市| 武胜县| 凤翔县| 旬邑县| 壤塘县| 红河县| 上思县| 虞城县| 丘北县| 枣庄市| 东乡县| 塘沽区| 柏乡县| 贡觉县| 泗阳县| 布尔津县| 尚义县| 恩施市| 灵武市| 威海市| 洮南市| 扶余县| 定边县| 密云县| 德钦县| 合作市| 河东区| 汪清县|