I’m trying to set up my old CodeIgniter-based admin application on a new PC running Ubuntu and Apache. The structure of my application is as follows:
apps
- api_user
- application
- public_html
- web_admin
- application
- public_html
I’ve set up a virtual host for the web_admin
part of the application. Here’s my Apache virtual host configuration:
<VirtualHost *:80>
ServerName admin.app-dev
DocumentRoot "/var/www/myapp/apps/web_admin/public_html/"
<Directory "/var/www/myapp/apps/web_admin/public_html/">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog /var/log/apache2/error.log
LogLevel warn
CustomLog /var/log/apache2/access.log combined
</VirtualHost>
I’ve also updated the /etc/hosts
file:
127.0.0.3 admin.app-dev
The app loads the login page fine, but when I try to submit the login form, it makes a request to http://admin.app-dev/admin_api/login
, which results in a 404 Not Found error.
Here’s what I’ve tried so far:
- Verified that the
mod_rewrite
module is enabled. - Checked that the
.htaccess
file in thepublic_html
directory contains the necessary rewrite rules:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
- Ensured that the base URL in the CodeIgniter
config.php
is set tohttp://admin.app-dev/
. - Verified that the
routes.php
file has the correct routes foradmin_api/login
. - Checked the Apache error logs (
/var/log/apache2/error.log
), but no errors are being logged. - Set the
ENVIRONMENT
todevelopment
in CodeIgniter’sindex.php
file to enable detailed error reporting, but no additional information appears.
However, when I try to access http://admin.app-dev/index.php/admin_api/login
, it works, which suggests that URL rewriting might be the issue. But all necessary rewrite rules seem to be in place.
My environment:
- OS: Ubuntu 22.04
- Apache version: 2.4.52
- PHP version: 8.1
- CodeIgniter version: 3.x
Additional Information:
- Permissions and ownership for the
public_html
directory and files are set towww-data:www-data
, with755
permissions. - This same setup worked perfectly on my old development machine.
Question:
Why does the URL http://admin.app-dev/admin_api/login
result in a 404 error, and how can I resolve this issue to restore the URL rewriting functionality?