apache去掉index.php
1.编辑conf/httpd.conf配置文件
#LoadModule rewrite_module modules/mod_rewrite.so 把该行前的#去掉
同时对应Directory下要配置 AllowOverride All
2.在 CI 根目录下(即在index.php,system的同级目录下)新建立一个配置文件,命名为: .htaccess 内容如下:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|robots\.txt)
RewriteRule ^(.*)$ index.php/$1
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(application|modules|plugins|system|themes) index.php/$1 [L]
3.把system/application/config/config.php 中$config[‘index_page‘] = "index.php";改为$config[‘index_page‘] = "";
4.重启apache
nginx去掉index.php
1.编辑nginx.conf文件
vi /usr/local/xxxxx/nginx/conf/nginx.conf
#nginx去掉index.php
location / {
rewrite ^/$ /index.php last;
#防止某些文件夹被直接访问
rewrite ^/(?!index\.php|robots\.txt|uploadedImages|resource|images|js|css|styles|static)(.*)$ /index.php/$1 last;
}
2.config/config.php下配置$config[‘index_page‘] = ‘‘;
3..重启nginx