drag2458 2014-10-02 09:52
浏览 53

CodeIgniter路由 - 移动到新服务器后出现404错误

At the moment I am trying to move a website to a new web server. The site uses CodeIgniter and on the old server, every route worked. On the new server none of them are working, even though I copied the entire website from the old server. This means there are no differences in .htaccess files, since the two servers contain the exact same website. Not even the default routes are working, just the home page (index.php). I included the code in .htaccess to remove 'index.php' from routed URLs, but that also does not work.

If I try to visit '1.1.1.1/~user/employees' it will give me a 404 error, which means that the CodeIgniter route is not working. The controller file is located at /application/controllers/employees.php, so I am not sure what causes the problem.

I am aware of the similar posts on the site here, but none of them could solve my problem. Configuration of the config/config.php is (partly) as follows:

$config['base_url'] = '1.1.1.1/~user';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';

I have tried to change the base_url, but it still does not work if it's empty. Changing uri_protocol to REQUEST_URI or PATH_INFO also does not work. Also, if I try 1.1.1.1/~user/index.php/employees (so put 'index.php/' in between) I still cannot reach the page. I checked some Apache settings as well, AllowOverride is set to ALL and the mod_rewrite module is installed and enabled. Is there perhaps something else concerning differences in both server's configurations that I could have missed?

EDIT: I think I am a bit closer to finding out what the problem is. It is either something with Apache or .htaccess (but I already tried many things) or it has to do with the fact that the server URL is 1.1.1.1/~user rather than 2.2.2.2 as it was on the old server. Maybe I should change the baseurl or location of my .htaccess? This looks similar to my problem, but moving the .htaccess did not fix the problem: Url routing errors in php in codeigniter. I might try re-installing Apache.

  • 写回答

1条回答 默认 最新

  • dongnai3960 2014-10-02 10:03
    关注

    I think that you firstly should find out what happened.

    • All requests to CI go through index.php, so you just echo something and exit in index.php file at the first line.

    • If the page display what you echoed that means there is something wrong in CI, otherwise that's not because of CI. And you can focus on what cause the problem.

    Sorry about my English.

    评论

报告相同问题?

悬赏问题

  • ¥35 平滑拟合曲线该如何生成
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集