I have changed permalink settings in my WordPress website and now all pages return 404 error.
I have tried the following (none of them worked for me)
- Removing .htaccess file and change permalink configuration from WordPress admin panel so it overrites the file with a correct .htaccess configuration
- Cheching whether Apache2 server has Allow Override directive (It has the directive enabled)
- Checking file permissions (they are okey — -rw-r–r– )
- Uninstalling all plugins
2
Answers
Try calling
flush_rewrite_rules
(https://developer.wordpress.org/reference/functions/flush_rewrite_rules/).Just put it into your active theme’s
functions.php
file (e.g. at the beginning) and refresh your page. Then remove it.Go to Settings » Permalinks, and simply click on the Save Changes button. This will update your permalinks settings and flush rewrite rules. In most cases, this solution fixes the WordPress posts 404 error. However, if it does not work for you, then you probably need to update your .htaccess file manually.
You can also manually add this code in your .htaccess file: