将index.php从Code Igniter URL中取出

时间:2011-01-20 23:49:27

标签: codeigniter codeigniter-url

我对Code Igniter很新(就像我刚刚完成他们的“官方”视频教程),我想知道是否有办法清理URL更多。

基本上,是否有一些设置可以将“index.php”保留在URL之外?

所以不要这样......

  

http://localhost/codeigniter/index.php/blog/comments/

......你看到了这个:

  

http://localhost/codeigniter/blog/comments/

或者我是否必须使用.htaccess重写URL?

3 个答案:

答案 0 :(得分:3)

使用.htaccess更容易,其他方式可能不适用于共享主机我猜。 我想这就是:

<IfModule mod_rewrite.c>
    RewriteEngine On

 RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d

    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

答案 1 :(得分:2)

请按照以下说明操作。

http://codeigniter.com/wiki/mod_rewrite/

简单到1个htaccess文件和1个配置文件修改

答案 2 :(得分:1)

你没有“拥有”使用htaccess但是以任何其他方式做这将是一大堆kludge(想想在php中从... / index.php / ...重定向到非index.php版本)。

任何值得他们的盐的php dev都会在.htaccess中执行。