CodeIgniter Forums
Following news section tutorial - 404 Page Not Found - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Following news section tutorial - 404 Page Not Found (/showthread.php?tid=62074)



Following news section tutorial - 404 Page Not Found - PamelaK - 06-07-2015

Hi

I am new to php and have just recently downloaded CodeIgniter and am following the tutorial for the news section. The problem I am encountering is with the following code from the news overview page index.php here application/views/news/index.php.

Code:
    <p>
      <a href="<?php echo $news_item['slug'] ?>">View article</a>
    </p>

It get the 404 Page Not Found error (details showing in URL is http://localhost/CodeIgniter/index.php/the_data_from_my_database_field_slug)

But when I put in this code, it displays the data from $news_item['slug'] Ok
Code:
    <!-- test div -->
    <div>
        <?php echo $news_item['slug'] ?>
    </div>

I have gone back and checked all my code against that in the tutorial and this is not the problem. Has anyone else encountered this problem?


RE: Following news section tutorial - 404 Page Not Found - Blair2004 - 06-07-2015

Hi I don't know the tutorial you’re talking about. But you bette var_dumping this var in order to see if the value is a valid controller or if its well remapped (_remap)


RE: Following news section tutorial - 404 Page Not Found - RogerMore - 06-12-2015

Hey PamelaK,

Did you add the routes to your routes config file?

Code:
$route['news/(:any)'] = 'news/view/$1';
$route['news'] = 'news';
$route['(:any)'] = 'pages/view/$1';
$route['default_controller'] = 'pages/view';

If you didn't it will never work.

-Roger