CodeIgniter初学者在这里。我网站的基本网址是' http://localhost/routing/'。
// config.php
$config['base_url'] = 'http://localhost/routing/';
我只想尝试路由网址http://localhost/routing/admin'使用以下规则管理控制器,但它不起作用。相反,我必须使用' http://localhost/routing/index.php/admin'。
$route['default_controller'] = 'seasons';
$route['admin'] = 'admin';
$route['404_override'] = '';
问题:有没有办法删除' index.php'来自网址?
答案 0 :(得分:5)
在.htaccess文件和config.php中进行更改
<强>应用/ config.php中强>
$config['index_page'] = '';
<强>的.htaccess 强>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
答案 1 :(得分:4)
有没有办法从网址中删除'index.php'?
是的,除了very popular question on SO之外,还有in the CodeIgniter documentation(这非常好,我强烈推荐阅读)。
答案 2 :(得分:0)
在你的.htaccess
中写下这个。另请查找其他信息:Codeigniter Guide
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt) # exceptions
RewriteRule ^(.*)$ /index.php/$1 [L]