当前位置:首页>正文

CI框架怎么去掉隐藏入口文件index.php

2024-01-12 22:10:30 互联网 未知

CI框架怎么去掉隐藏入口文件index.php?

1.


  LoadModule rewrite_module modules/mod_rewrite.so,把该行前的#去掉。


  搜索 AllowOverride None(配置文件中有多处),看注释信息,将相关.htaccess的该行信息改为AllowOverride All。


  2.在CI的根目录下,即在index.php,system的同级目录下,建立.htaccess,直接建立该文件名的不会成功,可以先建立记事本文件,另存为该名的文件即可。内容如下(CI手册上也有介绍):


  RewriteEngine on


  RewriteCond $1 !^(index\.php|images|robots\.txt)


  RewriteRule ^(.*)$ /index.php/$1 [L]


  如果文件不是在www的根目录下,例如我的是:http://localhost/CI/index.php/,第三行需要改写为RewriteRule ^(.*)$ /CI/index.php/$1 [L]。


  另外,我的index.php的同级目录下还有js文件夹和css文件夹,这些需要过滤除去,第二行需要改写为:RewriteCond $1 !^(index\.php|images|js|css|robots\.txt)。


  3.将CI中配置文件(system/application/config/config.php)中$config[index_page] = ”index.php”将$config[index_page] = ”" 。


  这样就可以了,不过千万记得从启apache。


  如上的重定向规则在linux下也可以写成一个.htacess文件。放到网站的根目录。

相关文章