我正在使用codeigniter框架。现在我想从URL
中删除index.php示例:
其实我想要删除" index.php"在URL的末尾,
现在我的config.php $config['index'] = ''
;
请有人帮我怎么做?
答案 0 :(得分:0)
在项目的根目录中添加htacess文件
RewriteEngine on
# If the request is not for a valid directory
RewriteCond %{REQUEST_FILENAME} !-d
# If the request is not for a valid file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond $1 !^(index\.php)
RewriteRule ^(.*)$ index.php/$1 [L]
答案 1 :(得分:0)
我在所有CodeIgniter项目的root
中都有这个添加.htaccess文件
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# Removes index.php from ExpressionEngine URLs
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteCond %{REQUEST_URI} !/system/.* [NC]
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]
# Directs all EE web requests through the site index file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
您可能还需要在Apache
中启用rewrite_module
模块