Welcome Guest, Not a member yet? Register   Sign In
What is causing 404 error in CodeIgniter?

I am attempting to install the latest version of CodeIgniter in a subdirectory, which has been successful thus far. However, I now aim to eliminate "index.php" from the URL. As a result, I have created an .htaccess file in the subfolder with the following directives:

RewriteEngine On
RewriteBase /dev/

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

# Disallows access to the system and application folders by users
# This enables the creation of a System.php controller, which was previously impossible
# Replace 'system' if your system folder has been renamed
RewriteCond %{REQUEST_URI} ^system.*
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php/$1 [L]

# Checks if the user is attempting to access a valid file, such as an image or CSS document
# If not, the request is redirected to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
The name of the subdirectory is "dev", and the webroot (parent folder) is empty, containing only an index.html file. The resulting file structure is as follows:

        CodeIgniter installation here
Mod-rewrite is enabled, but I am receiving a 404 error when attempting to call URLs without "index.php". Can you provide any insight into why this may be happening?

to remove index.php from URL you do not have to change in .htacess

you can achieve the same just by changing in
PHP Code:
public string $indexPage ''

although if you still wanna do it using .htaccess and if your server supports rewriting URLs you can easily remove this file with URL rewriting.
you can go through official docs. removing-the-index-php-file
Learning Codeigniter 


I'm following the user guide tutorial.

For a start I see the php spark serve, serves my application in port 8081 and not 8080 and I don't know why, since I've done just the basic configuration yet.

Also, when trying to open the /pages or /home or /about page, I always get a 404 : Controller or its method is not found: \Config\Pages::view.

As the code is trying to find my controllers inside of folder Config and not folder Controllers.

I have the correct namespace in Routes.php : $routes->setDefaultNamespace('App\Controllers');
I didn't touch anything of that yet.

Thank you very much if you can help me !!

Kind regards,


Theme © iAndrew 2016 - Forum software by © MyBB