使用.htaccess从codeigniter中的url中删除index.php?

时间:2015-09-30 04:15:07

标签: .htaccess codeigniter

http://localhost/codeigniter/index.php/user/main_page

如何从此网址中删除index.php?

3 个答案:

答案 0 :(得分:1)

试试这个文件。我在我的项目中使用它

https://github.com/eborio/curso-de-codeigniter/tree/master/02-primeros-pasos

答案 1 :(得分:0)

答案在帖子中说明这个问题是完整的。

This is the answer

肖恩·维埃拉的回答:

  

如果您使用Apache,请在根网站中放置.htaccess文件   包含以下内容的目录:

RewriteEngine on
RewriteCond $1 !^(index\.php|[Javascript / CSS / Image root Folder name(s)]|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
     

另一个好的版本位于:

     

http://snipplr.com/view/5966/codeigniter-htaccess/

答案 2 :(得分:0)

试试这个:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

替换:

$config['index_page'] = "index.php"
to
$config['index_page'] = ""

 if it still not work try to replace:

 $config['uri_protocol'] = "AUTO"
//replace with the below code
$config['uri_protocol'] = "REQUEST_URI"

了解更多详情:http://w3code.in/2015/09/how-to-remove-index-php-file-from-codeigniter-url/请查看