“Page not found” error after changing permalink WordPress
Feb 12
Facing “page not found” error that appears when changing to “Pretty” Permalinks in WordPress is very common. Actually I faced this error almost in each time I decide changing the Permalinks. It always takes lot of time and effort from me to fix it, so I decided to stop this continuos pain and write this post listing the possible problems and their fixes for you guys.
There are two assumptions when writing this post:
- You are on Ubuntu server
- You are using Apache server
If this is not the case you will have to find the command for your OS that do what I’m doing here.
Now the next time you face Page not found issue follow this simple checklist :
- Does .htaccess file exists?
- Is the .htaccess file editable?
- Change the permission of your .htaccess to 777 (or whatever works in your server), and set the Pemalink again. Once the WordPress added the required code in .htaccess, change back the permission of .htaccess to 644.
- Add the following code to your .htaccess file manually:
1234567891011# BEGIN WordPress<IfModule mod_rewrite.c>RewriteEngine OnRewriteBase /RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule . /index.php [L]</IfModule># END WordPress - Is Rewrite module enabled in your server?
- Does Apache knows about .htaccess file?
- Search for the “AllowOverride” option
- /etc/apache2/apache2.conf
- /etc/apache2/httpd.conf
- /etc/apache2/sites-enabled/000-default
- /etc/apache2/sites-available/yourdomain.com
- Make sure that the Permalinks custom setting is correct
- Make sure that there is no “index.html” in your WordPress base directory
- Does your server allow the symlinks?
Whenever you change the Permalinks, WordPress should update the .htaccess file for you. Sometimes if the file is not created WordPress won’t create it automatically. This is simply because it may not have the permission to do that. So if you can’t find the file in the root of the WordPress installation (After showing the hidden files) create it yourself.
If the file is there, check the modification time of the file. Then change the Permalink settings from WordPress hit save and go back to check the time again. If it’s not updated then WordPress doesn’t have the permission to update it. To update it you can do one of the following:
If you are in a shared server, simply ask the technical supports whether this module is enabled. If you are on your server try running this command in your terminal :
1 |
sudo a2enmod rewrite |
if you get “Module rewrite already enabled” then move to the next step or else restart your apache server using :
1 |
sudo service apache2 restart |
Open apache2.conf file (normally you will find it in /etc/apache2) and make sure that this line is there:
1 |
AccessFileName .htaccess |
Try searching for “AllowOverride” in these files:
if you found it in this form :
1 |
AllowOverride None |
just comment it by adding # in front of it. Then restart Apache and check if the Permalinks start working.
If you are using Permalinks custom settings make sure that /index.php/ is not written in front of your Permalink.
Just list the files in base directory of WordPress and make sure
Try adding the following code to the top of your .htaccess file :
1 2 |
Options +FollowSymlinks RewriteEngine on |
This was my checklist that I used when trying to fix this issue. If all these steps didn’t help you then the problem is definitely is not in your server. Make sure it’s not a theme or a plugin problem. Try disabling all your plugins and changing your theme.
if you have any more items to add to this checklist please tell me and I will be happy to add them.
I really hope this post will save your time.
i have to thank you to benefit me with such a good text.
You are welcome.
What is a great great well written post. I have been search for quite a while and this is the only one that solved my problem
Thanks a lot for the great feedback and I’m really glad it helped you.
Muy contenta con este artículo, muchas gracias por compartir tu conocimiento. Me pase un día entero buscando arreglar este problema y aquí estaba la solución. Muy agradecida. Miles de estrellas para ti.
Thanks!! this helped me a lot 🙂
Glad to know that 🙂
You’re welcome.