doupinge9055 2012-04-13 07:02 采纳率: 100%
浏览 38
已采纳

codeigniter不会重定向网址

I did what it is said in the htaccess:

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

I put the above, so that I will be able to do this:

http://localhost/Speakom2/Home/index

Instead of:

http://localhost/Speakom2/index.php/Home/index

But it doesnt work... I get 404 error..how to fix this so it works?!?

Controller:

class Home extends CI_Controller {

public function Index() 
{
    $this->load->view('welcome_message');
}

}

htaccess:

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

4条回答 默认 最新

  • douran9707 2012-04-13 07:08
    关注

    when you are running on the local host your web root is /localhost/mysite/ but in the real host your root is /mysite : so in localhost use :

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

    note that index.php without /

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?