AWS WordPress Install – pages/posts 404 on restart until updating permalinks

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

  1. logging into my instance through /wp-login
  2. going to the /options-permalinks page
  3. 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.

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

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.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x