If Apache serves the wrong directory for WordPress, check VirtualHost mapping, DocumentRoot, and rewrite logic before changing WordPress files.
1) Inspect active virtual hosts
sudo apache2ctl -S
Verify expected host points to the correct site config and root path.
2) Confirm DocumentRoot and Directory rules
sudo nano /etc/apache2/sites-enabled/your-site.conf
Ensure DocumentRoot and matching <Directory> blocks target the same path.
3) Review rewrite and redirect rules
- Avoid conflicting rewrites in both vhost and .htaccess.
- Keep one canonical redirect policy.
4) Test and reload
sudo apache2ctl configtest
sudo systemctl reload apache2
Validation Commands
apachectl -t
curl -I https://www.wordpresshosting.solutions/
sudo tail -n 120 /var/log/apache2/error.log
Further reading: Apache HTTP Server Documentation
Related posts: