dshmvqnl98119 2014-10-02 19:36
浏览 37
已采纳

CodeIgniter / Bonfire应用程序中的路由显示未找到的页面

I have a CodeIgniter/Bonfire application with routes defined.
The main URL works fine but the subpages are not redirected.
When I enter the URL:

http://xtrack.local/news/1393/litany-look

I got error PAGE NOT FOUND and looks like it cannot find the base_url:

Not Found
The requested URL /news/1393/litany-look was not found on this server.

Here is my routes file in application/config/routes.php :

$route['news/(:any)']                   = 'home/news/$1';

And my config file define my base_url :

switch (ENVIRONMENT)
    {
        case 'development':
            $config['base_url'] = 'http://xtrack.local';
            break;

        default:
            exit('The application environment is not set correctly.');
    }

EDIT1 : I found a way to access my news page through the index.php page:

http://xtrack.local/index.php/news/1393/litany-look
  • 写回答

1条回答 默认 最新

  • dongxie5698 2014-10-03 00:12
    关注

    The index.php file is necessary because this is the entry point of the application that gets all components ready, including the router. You can use an .htaccess file on apache hosts to pass the request to this file implicitly though. From the manual:


    By default, the index.php file will be included in your URLs:

    example.com/index.php/news/article/my_article

    You can easily remove this file by using a .htaccess file with some simple rules. Here is an example of such a file, using the "negative" method in which everything is redirected except the specified items:

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

    In the above example, any HTTP request other than those for index.php, images, and robots.txt is treated as a request for your index.php file.


    So then the URL would become example.com/news/article/my_article, or in your case the one at the start of your post.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog