CodeIgniter的伪静态配置

不问归期 提交于 2019-12-03 07:01:46

基本信息

  • CodeIgniter 版本:3.1.8
  • Nginx: Tengine/2.1.2 (nginx/1.6.2)
  • MySQL: Ver 14.14 Distrib 5.6.33, for Linux (x86_64) using EditLine wrapper
  • PHP: 5.6.30
  • Zend Engine : v2.6.0
  • CentOS release 6.8 (Final)

Nginx

server {
        listen       80;
        server_name  yml.nnkh1314.com;

        root   "/disk/www/yml_nnkh1314_com";
        index index.php  index.html index.htm;

        location / {
                # 这里使用try_files进行url重写,不用rewrite了。
                try_files $uri $uri/ /index.php?$query_string;
        }

        location ~ \.php($|/) {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_split_path_info ^(.+\.php)(.*)$;
            fastcgi_param   PATH_INFO $fastcgi_path_info;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }

        location ~ /\.ht {
                deny  all;
        }
}

Apache

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

IIS

<?xml version="1.0" encoding="UTF-8"?>
  <configuration>
      <system.webServer>
        <rewrite>
          <rules>
              <rule name="Index">
              <match url="^(.*)$" />
              <conditions>
                <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
              </conditions>
                    <action type="Rewrite" url="index.php/{R:1}" />
            </rule>
          </rules>
        </rewrite>
      </system.webServer>
</configuration>

Godaddy

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteRule ^index.php/(.*)$ [L]
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!