Fixing 404 Errors on Every Page

If the home page loads but every other link returns a 404, URL rewriting is not working. The web server is looking for real directories instead of handing the request to WHMAZ.

1. Confirm the .htaccess file exists

On Apache, check for .htaccess in the installation root. It is a hidden file, so it is easily missed when uploading — list it with ls -la. It should contain:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

2. Enable mod_rewrite

a2enmod rewrite
systemctl restart apache2

3. Allow .htaccess to take effect

Apache ignores .htaccess entirely unless the directory's configuration permits it. In your virtual host, the directory block needs:

AllowOverride All

Restart Apache after changing it. This catches people out constantly — the file is present and correct, but the server has been told not to read it.

4. Check the base URL

In application/config/config.php, confirm base_url matches the address you actually browse to, including https:// and any subdirectory, with a trailing slash.

On Nginx

Nginx does not read .htaccess at all. Add the equivalent to your server block:

location / {
    try_files $uri $uri/ /index.php$is_args$args;
}

Reload Nginx afterwards.

Was this article helpful?