AWS Wordpress Install - pages/posts 404 on restart until updating permalinks
-
20-05-2021 - |
Question
I have launched a WordPress instance on AWS using elastic beanstalk. Every now and then AWS restarts my server and when it does all my pages/posts links switch to returning 404.
I can fix this by
- logging into my instance through
/wp-login
- going to the
/options-permalinks
page - hitting [save changes] (without making any changes)
I am wondering if there is something I can add to my wp-config.php (or similar) to do the same work at launch every time so that I don't have a broken website randomly sitting there waiting for me to notice?
Any help would be amazing.
Solution
This answer was based off the comment from @Rup on the question. I needed to add a .htaccess
file to my source. I did this with the default contents:
# BEGIN WordPress
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
which I got from here: https://wordpress.org/support/article/htaccess/
Adding this at the root of my deploy package (uploaded source) and the problem went away.