404 Page Not Found The page you requested was not found. Code igniter

404 Page Not Found The page you requested was not found. Code igniter

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

Resolving the "Page Not Found" Error in CodeIgniter Deployments

When migrating a local CodeIgniter application to a shared hosting environment, encountering a generic 404 Page Not Found error is a common stumbling block. This issue usually stems from how web servers interpret requests versus how legacy PHP frameworks like CodeIgniter expect them to be routed. In your specific scenario involving the deployment of an app built with CodeIgniter on a temporary free server, the combination of an empty .htaccess file and specific routing configurations is almost certainly the culprit.

The root cause lies in the interaction between your web server (likely Apache) and CodeIgniter's Front Controller design. CodeIgniter relies on a single entry point, typically index.php, to catch all incoming requests and route them internally. However, modern web servers do not automatically prepend this file to every URL; they treat requests as static files first. When you navigate to http://hello.hostingsiteforfree.com/ or any sub-path, the server attempts to serve a file directly from the document root. Since a file named exactly that path does not exist in most deployments, the server returns a 404 immediately before your application's routing logic ever executes.

To resolve this, you must configure the .htaccess file in your web root to intercept all requests and redirect them to index.php. An empty .htaccess file leaves no mechanism for this interception. You need to add the following directives to the top of your .htaccess file:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . index.php [L]
</IfModule>

This configuration ensures that any request not matching an existing file or directory is rewritten to index.php. Once the request hits your entry point, CodeIgniter can process it according to its internal routing rules defined in routes.php and application/config/config.php.

Another critical area to verify is your config.php settings. You mentioned updating $config['base_url'] to http://hello.hostingsiteforfree.com/. While setting the base URL is essential for generating correct asset links (CSS, JS) and redirects, it does not fix routing issues on its own. Ensure that $config['index_page'] = 'index.php' remains set unless you have explicitly configured your .htaccess to bypass index.php, which is not standard practice for CodeIgniter.

Additionally, review your routes.php. You have defined a default controller as loginController. In newer versions of CodeIgniter (3.x and above), the routing syntax has changed significantly compared to legacy versions (1.x or 2.x). If you are using an older framework version, the syntax $route['404_override'] = '' is correct. However, if you are on a modern version, you might be dealing with URI filtering rules that block specific paths. The "Page Not Found" error often suggests that the server itself is blocking the request before reaching CodeIgniter, which brings us back to the .htaccess requirement.

If you encounter persistent issues after adding the .htaccess rules, check your application/config/index.php file (if it exists) or ensure that your virtual host configuration in the hosting control panel points to the correct directory containing your index.php. Shared hosting environments sometimes have strict file permissions; verify that index.php and your controller files are readable by the web server.

Finally, consider the implications of using free hosting for a production application. While platforms like 1FreeHosting provide a starting point, they often lack the flexibility to install custom modules or configure .htaccess rules strictly as needed without root access. If modifying the .htaccess file is not possible due to hosting restrictions, you may need to look into alternative deployment strategies or consider moving to a more robust shared hosting provider that supports CodeIgniter natively with full rewrite module capabilities.

Our network