WordPress permalinks not working on Ubuntu Apache is a common issue that can frustrate developers and website owners alike. If URLs containing index.php work correctly but clean, SEO-friendly URLs return a 404 error, the problem is usually related to Apache rewrite rules or .htaccess configuration.
I recently encountered this issue while working on a local WordPress installation, and the fix turned out to be straightforward once the root cause was identified.
In this guide, I’ll show you how to troubleshoot and fix WordPress permalinks on Ubuntu running Apache.
Table of Contents
ToggleThe Problem
Your website may behave like this:
✅ Working URL:
http://localhost/themeforest/index.php/bookpress/
❌ Not Working URL:
http://localhost/themeforest/bookpress/
Common symptoms include:
- WordPress homepage loads correctly
- Posts and pages work when
index.phpis included - Pretty permalinks return a 404 error
- WordPress permalink settings are already configured
- Apache
mod_rewriteappears to be enabled
Why WordPress Permalinks Stop Working
WordPress relies on Apache rewrite rules stored in the .htaccess file to convert clean URLs into requests that WordPress can process.
If Apache ignores the .htaccess file or rewrite rules are not being applied correctly, WordPress cannot resolve those URLs.
The most common causes are:
mod_rewritedisabled- Incorrect
.htaccessrules AllowOverride Nonein Apache configuration- Permissions issues
- Corrupted permalink settings
Step 1: Verify Apache Rewrite Module Is Enabled
Start by checking whether the Apache rewrite module is active:
sudo apachectl -M | grep rewrite
Expected output:
rewrite_module (shared)
If nothing is returned, enable it:
sudo a2enmod rewrite
sudo systemctl restart apache2
Step 2: Check Your WordPress .htaccess File
For WordPress installed inside a subdirectory such as /themeforest/, your .htaccess file should look similar to this:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /themeforest/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /themeforest/index.php [L]
</IfModule>
# END WordPress
Make sure the directory name matches your actual installation path.
Step 3: Verify Apache Is Reading .htaccess
One of the most overlooked troubleshooting steps is confirming whether Apache is actually processing the .htaccess file.
Add an invalid directive temporarily:
INVALID_TEST
Refresh your website.
What the Results Mean
If you receive:
500 Internal Server Error
Apache is reading the .htaccess file.
If the website continues loading normally, Apache is ignoring .htaccess completely.
This test quickly identifies whether the issue is related to rewrite processing.
Step 4: Check AllowOverride Settings
The most common culprit on Ubuntu Apache servers is:
AllowOverride None
Check your Apache configuration:
grep -R "AllowOverride" /etc/apache2/
If you find:
AllowOverride None
Apache will ignore WordPress rewrite rules entirely.
Step 5: Enable .htaccess Processing
Open Apache configuration:
sudo nano /etc/apache2/apache2.conf
Locate:
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
Change it to:
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Save the file and restart Apache:
sudo systemctl restart apache2
This allows WordPress rewrite rules to function properly.
Step 6: Refresh WordPress Permalink Rules
After updating Apache settings:
- Log in to WordPress Admin.
- Navigate to Settings → Permalinks.
- Click Save Changes.
No need to modify the structure—simply saving flushes WordPress rewrite rules.
Step 7: Remove Apache ServerName Warning (Optional)
If Apache displays:
AH00558: Could not reliably determine the server's fully qualified domain name
Edit:
sudo nano /etc/apache2/apache2.conf
Add:
ServerName localhost
Restart Apache:
sudo systemctl restart apache2
This removes the warning and keeps your Apache logs cleaner.
Final Result
Once AllowOverride All is enabled and WordPress permalinks are refreshed, clean URLs should work correctly.
✅ Working:
http://localhost/themeforest/bookpress/
❌ No longer necessary:
http://localhost/themeforest/index.php/bookpress/
Your WordPress site will now support SEO-friendly URLs and proper permalink functionality.
Final Thoughts
When WordPress permalinks are not working on Ubuntu Apache, the issue is often not WordPress itself. In many cases, Apache is configured with AllowOverride None, preventing .htaccess rewrite rules from being processed.
By enabling AllowOverride All, verifying mod_rewrite, and refreshing WordPress permalink settings, you can usually resolve the problem within minutes.
If you’re facing WordPress development, server configuration, website speed, hosting optimization, or technical SEO challenges, professional troubleshooting can save hours of frustration.
Need Help?
👉 Need help with WordPress development, SEO, website security, or hosting optimization? Contact me today:
🚀 Contact Me Today