0

我在本地机器上安装了 CodeIgniter。我hosts在 Windows 和 Apache 配置中使用了文件来使其在我的真实域名下工作(例如。site.com)。效果很好,所以今天我把所有东西都上传到了我的主机上。我更改了hostsApache 配置,通过刷新 DNS ipconfig /flushdns,现在输入某些 URL(games)给了我 404。

我的控制器名称以大写开头,但我的路由设置如下:

$route['Games/(:num)/(:any)'] = 'Games/Game/$1';
$route['games/(:num)/(:any)'] = 'Games/Game/$1';

通过输入games/14/gameGames/14/game不起作用。

搜索图像(使用merahulpk 给出的解决方案)也不起作用。

会是什么?

不幸的是,它仍在开发中,所以我现在还不能给你地址。

- 编辑 -

图像包含脚本:

views/game.php

<?php
    $image_path = $this->config->item('base_path').'images/games/'.$info['id'].'-s.jpg';
    if(file_exists($image_path)) {
        $small = $this->config->item('base_url').'images/games/'.$info['id'].'-s.jpg';
        $big = $this->config->item('base_url').'images/games/'.$info['id'].'-b.jpg';
    } else {
        $small = $this->config->item('base_url').'images/games/none-m.png';
        $big = $this->config->item('base_url').'images/games/none-m.png';
    }
?>

config/sit-config.php

<?php

$config['base_url'] = "http://".$_SERVER['SERVER_NAME'] . str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);

if(!defined('DOCUMENT_ROOT')) define('DOCUMENT_ROOT',str_replace('system/application/config','',substr(__FILE__, 0, strrpos(__FILE__, '/'))));

$config['base_path']    =   constant("DOCUMENT_ROOT");
?>
4

1 回答 1

3

不要在您的路线中使用大写字母。像这样使用所有小写:

$route['games/(:num)/(:any)'] = 'games/game/$1';

如果您使用大写的控制器名称,路由将不起作用。至于方法名称,它们可以是小写或大写,两者都可以......不需要重复的路线!

于 2012-09-27T08:35:14.130 回答