Solving the page not found issue when using permalink
This post is about how to solve the page not found problem when using the Permalinks feature of WordPress in Raspberry Pi.
About the Issue
When using “Post Name” or “Day and name” as the permalink, a not found error occurs when accessing the link in the WordPress page.
However, this problem doesn’t exist when using the “Plain” permalink.
The Solution
It seems the problem is caused by Apache server prohibits using an .htaccess file to apply URL rewrite rules. Below are the steps to enable it.
Make sure /var/www/html/.htaccess file contains the following:
# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
Enabling mod_rewrite
sudo a2enmod rewrite
Check default Apache configuration file (/etc/apache2/sites-available/000-default.conf) contains the following directives
<VirtualHost *:80>
<Directory /var/www/html>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
.....
Restart Apache
sudo systemctl restart apache2