This tutorial explains how to fix WordPress permalink problem, which occurs due to incomplete Apache2 webserver configuration.
When you try to change the Permalink structure in your
WordPress -> Settings -> Permalinks your posts, pages and menu links become unreachable.
This happens because
AllowOverride directive in your webserver configuration file is set to
None and does not allow the
.htaccess file to rewrite your website URLs.
AllowOverride directive in your webserver configuration file
/etc/httpd/conf/httpd.conf (CentOS) /
/etc/apache2/apache2.conf (Ubuntu) will help you resolve this problem.
- Configure Apache2
- Restart Apache2
- Configure WordPress
1. Configure Apache2
1.1. Firstly, you will need to edit the webserver configuration file.
1.2. Then, find the directive
AllowOverride None in your website directory part of configuration
<Directory "/var/www/html"> as in the sample output bellow. Change the
AllowOverride None directive to
AllowOverride All. After that you can save and exit out of the file.
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be “All”, “None”, or any combination of the keywords:
# Options FileInfo AuthConfig Limit
2. Restart Apache2
You need to restart your Apache2 webserver for changes to take affect.
systemctl restart httpd.service
3. Configure WordPress
Finally, you need to configure the permalinks in your
WordPress -> Settings -> Permalinks. Choose the permalink option that is most suitable for you and then save the changes. Then load your WordPress website in your browser and open a post, page or menu link. The posts, pages and links are now loading normally and with the permalink structure, which you have selected.
You have changed the settings in your webserver configuration file, then rebooted your webserver. This allows mod_rewrite module to rewrite your WordPress website URLs according to the rules in your .htaccess file.