Welcome Guest, Not a member yet? Register   Sign In
Tutorial - Static Pages - about.php page showing 404 error
#1

[eluser]osxxso[/eluser]
Followed the instruction... user_guide/tutorial/static_pages.html

running xampp ( http://site.local)

When I got to http://site.local ( i see header.php, home.php, and footer.php )

When I go to http://site.local/about ( i get Error 404 )

When I go to http://site.local/index.php/about ( I see header.php, about.php and footer.php )

What do I need to change to see about at http://site.local/about ?

Bye the way, my application and system directories were renamed ( just so I know how to do this ) and placed above root ( additional security ).

index.php

Code:
$system_path = '../sysdir';
$application_folder = '../appdir';

routes.php

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

pages.php

Code:
<?php

class Pages extends CI_Controller {

public function view($page = 'home')
{
  if ( ! file_exists('../appdir/views/pages/'.$page.'.php'))
  {
   // Whoops, we don't have a page for that!
   show_404();
  };
  
  $data['title'] = ucfirst($page); // Capitalize the first letter
  
  $this->load->view('templates/header', $data);
  $this->load->view('pages/'.$page, $data);
  $this->load->view('templates/footer', $data);  
}
}

Thanks in advance!
#2

[eluser]smdbzdmr[/eluser]
I ask for same question maybe it helps you.

http://ellislab.com/forums/viewthread/214805/



Change index_page value in application/config/config.php
Code:
$config['index_page'] = '';

My htaccess
Code:
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /codeigniter/

    #Removes access to the system folder by users.
    #Additionally this will allow you to create a System.php controller,
    #previously this would not have been possible.
    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]
    
    #When your application folder isn't in the system folder
    #This snippet prevents user access to the application folder
    #Submitted by: Fabdrol
    #Rename 'application' to your applications folder name.
    RewriteCond %{REQUEST_URI} ^application.*
    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>

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

    ErrorDocument 404 /index.php
</IfModule>


Edit : this is a tutorial x) i just think you have an error, sorry Smile
#3

[eluser]osxxso[/eluser]
Solved:

Thanks! smdbzdmr for the code and pointing me in the right direction.

Followed these instructions.

Added this .htacces file to my public_html directory

Code:
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    #Removes access to the system folder by users.
    #Additionally this will allow you to create a System.php controller,
    #previously this would not have been possible.
    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]
    
    #When your application folder isn't in the system folder
    #This snippet prevents user access to the application folder
    #Submitted by: Fabdrol
    #Rename 'application' to your applications folder name.
    RewriteCond %{REQUEST_URI} ^application.*
    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>

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

    ErrorDocument 404 /index.php
</IfModule>

Edited appdir/config/config.php

CHANGED

Code:
$config['index_page'] = 'index.php';

TO

Code:
$config['index_page'] = '';




Theme © iAndrew 2016 - Forum software by © MyBB