codeigniter 去除index.php (nginx,apache) 通用方法


.htaccess文件配置

复制代码
1 <IfModule mod_rewrite.c>
2   RewriteEngine On
3   RewriteBase /
4   RewriteCond $1 !^(index\.php|assets|system|robots\.txt)  
5   RewriteRule ^(.*)$ /index.php/$1 [L,QSA]   
6 
7 </IfModule>
复制代码

简要说明:关键是这句:rewirteCond ,assets是目录。

apache的配置:

复制代码
 1 <VirtualHost *:80>
 2     ServerAdmin jjj@163.com
 3     DocumentRoot "d:/mywork/m"
 4     
 5     ServerName m.mimi.com
 6     
 7     <Directory "d:/mywork/m">    // 这里是项目的目录
 8         Options Indexes MultiViews FollowSymLinks 
 9         AllowOverride All
10         Order allow,deny
11         allow from all
12    </Directory>
13 </VirtualHost>
复制代码

简要说明:

ServerAdmin表示错误信息地址,如果发生错误发送到这个邮箱地址。

Indexes 的作用就是当该目录下没有 index.html 文件时,就显示目录结构,去掉 Indexes,Apache 就不会显示该目录的列表了。

Nginx配置几句

复制代码
1 location /
2         {
3             index index.php;
4             if (!-e $request_filename) {
5                     rewrite ^/(.*)$ /index.php?$1 last;
6                     break;
7             }
8         }


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM