Reputation: 1709
I have check the codeigniter user guide, But I was not lucky to solve my problem.
I have created a webpage on my localhost.
When I go to http://localhost/webpage/
it is okay. It will go to the default controller.
My default controller is Homepage
and there are methods named index
, guarantee
and about
When I go to my routes.php, I added this:
$route['guarantee'] = "homepage/guarantee";
$route['about_us'] = "homepage/about";
Then try to access it http://localhost/webpage/guarantee
and http://localhost/webpage/about_us
it show ERROR 404
But when I do it like this $route['default_controller'] = "homepage/guarantee";
The guarantee page will be displayed.
Can anyone help me with this issue? Thanks.
Upvotes: 0
Views: 363
Reputation: 83
In your application/config/config.php
, set $config['index_page']
to empty like
$config['index_page'] = '';
should work.
Upvotes: 1
Reputation: 60058
You need to remove index.php. In your application/config.php file change
$config['index_page'] = 'index.php';
to
$config['index_page'] = '';
Then put this .htaccess file in your root folder (in the same folder as where index.php is:
Options -Indexes
Options +FollowSymLinks
# Set the default file for indexes
DirectoryIndex index.php
<IfModule mod_rewrite.c>
# Activate URL rewriting:
RewriteEngine on
# do not rewrite links to the documentation, assets and public files
RewriteCond $1 !^(uploads|assets|js|css|images|img)
# but rewrite everything else
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.
ErrorDocument 404 index.php
</IfModule>
Upvotes: 1