CodeIgniter Forums
Tutorial - Static Pages - Printable Version

+- CodeIgniter Forums (
+-- Forum: Archived Discussions (
+--- Forum: Archived Development & Programming (
+--- Thread: Tutorial - Static Pages (/thread-48687.html)

Pages: 1 2

Tutorial - Static Pages - El Forum - 01-24-2012

I relocated the application and system folders above the root of the web server as suggested in the CodeIgniter Installation Instructions.

As a raw CodeIgniter beginner, I am now running the Static Pages tutorial.

After I had created the first few files, the URL index.php/pages/view kept returning Page Not Found.

After a fair bit of research, I changed the code in pages.php to ..

if ( ! file_exists(APPPATH.'/views/pages/'.$page.'.php')) {
// Whoops, we don't have a page for that!

The tutorial now works.

The code in the tutorial is currently ..
if ( ! file_exists('application/views/pages/'.$page.'.php')) {
Shouldn't this use the APPPATH definition?
Or is there an even better way to make sure the tutorial works in all cases?

Tutorial - Static Pages - El Forum - 01-25-2012

Did you change the paths to your system and application folder in codeigniters index.php file?

Tutorial - Static Pages - El Forum - 01-25-2012

- to 'C:/CI/applications' and 'C:/CI/system'

That is why APPPATH is set to the new (correct) location rather than the original location.

Tutorial - Static Pages - El Forum - 01-25-2012

I submitted a correction on github.

Tutorial - Static Pages - El Forum - 01-25-2012

[eluser]Phil Sturgeon[/eluser]
And it has been merged! Thanks for the fix guys.

Tutorial - Static Pages - El Forum - 02-20-2012

Thanks...that fixed it. But I am stuck on the routes.php thing. Not sure if I should do this in routes.php or .htaccess with mod_rewrite. I am trying to rewrite/reroute the url to without messing up other applications.
In routes.php I have:
$route['default_controller'] = 'news';
$route['404_override'] = '';

In .htaccess I have this one that I found:
<IfModule mod_rewrite.c>

    RewriteEngine On
    RewriteBase /

    ### Canonicalize codeigniter URLs

    # If your default controller is something other than
    # "welcome" you should probably change this
    RewriteRule ^(pages(/index)?|index(\.php)?)/?$ / [L,R=301]
    RewriteRule ^(.*)/index/?$ $1 [L,R=301]

    # Removes trailing slashes (prevents SEO duplicate content issues)
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.+)/$ $1 [L,R=301]

    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php/$1 [L]

    # Checks to see if the user is attempting to access a valid file,
    # such as an image or css document, if this isn't true it sends the
    # request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]


<IfModule !mod_rewrite.c>

    # Without mod_rewrite, route 404's to the front controller
    ErrorDocument 404 /index.php


Tutorial - Static Pages - El Forum - 02-20-2012

How many pages do you have like this? If not too many, you can list them all in a single route. There are many ways to do this.

Just one page...
$route['about'] = 'pages/view/$1';

Multiple pages...
$route['(about|some-other-page)'] = 'pages/view/$1';

class Pages extends CI_Controller {

  public function view($url_title = '')
    // page name is sent as $url_title automatically
    if ($url_title !== '')
      //check to see if page exists in database...

      //if so display it, if not show_404();

Tutorial - Static Pages - El Forum - 02-20-2012

I have multiple pages, but I am thinking that it might be better to just not put them in the pages folder if it means adding an extra configuration.

Tutorial - Static Pages - El Forum - 02-20-2012

I'm learning a lot from the posts. Little by little, I hope I get to improve myself. Thanks, everyone!

Tutorial - Static Pages - El Forum - 03-27-2012

I am running through the 'Tutorial − Static pages' and I am having a problem on the first page!

I have followed the instructions in detail and all I get is error 404.
I included the APPPATH suggestion above but still no joy.

I am not having any joy with the documentation/tutorials on this site, anybody know of what might be wrong on the Static Pages tutorial?

Thanks in advance,