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条)

报告相同问题?

悬赏问题

  • ¥15 求解 yolo算法问题
  • ¥15 虚拟机打包apk出现错误
  • ¥30 最小化遗憾贪心算法上界
  • ¥15 用visual studi code完成html页面
  • ¥15 聚类分析或者python进行数据分析
  • ¥15 逻辑谓词和消解原理的运用
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。