Experimenting with & Moving to AWS – Part 2

This is a follow up to my previous post – Experimenting with moving to AWS

All went well with AWS Lightsail, it’s a very serviceable VPS solution, but now I’ve had a bit of time in AWS I’ve migrated the site further to EC2. It was a simple enough process, snapshot the Lightsail machine and export that as an EC2 AMI and EBS snapshot, and then cloned the whole lot from London to Ireland. The move of regions was because I have some other data already in Ireland and wanted to keep the site in the same region now.

Off the back of all that I’ve got my IPv6 connectivity back to the site again, as Lightsail does not support IPv6 addressing, which is a bit of a negative point there of Lightsail. EC2 instances however, most certainly do support IPv6.

I’ve also gone as far as migrating DNS management into Route53 from Google Domains, mainly to simplify managing the domain zone.

The instance type the site is now running on is also one of the newer AMD EPYC EC2 instance types, which work out slightly cheaper than the equivalent Intel instances, so keep an eye on the instances suffixed with “a”, as you can save a bit of money there.

WordPress Permalinks & mod_rewrite in lighttpd

After switching to lighttpd away from Apache I was pretty pleased with the whole process, everything seemed to be working fine, with the exception of my permalink structure. Bad news, however this can be fixed;

In your lighttpd.conf or 10-rewrite.conf enable mod_rewrite and paste the following code (you will obviously need to edit the $HTTP[“host”] portion):

$HTTP["host"] =~ "www.mark-gilbert.co.uk" {
url.rewrite-final = (
# Exclude common directories
"^/(wp-admin|wp-includes|wp-content)/(.*)" => "$0",
# Exclude root php files
"^/(.*.php)" => "$0",
# Handle permalinks and feeds
"^/(.*)$" => "/index.php/$1"
)
}

These three rules should cover every plugin and bit of functionality within the system. If you have other folders which you will need to access without any redirection (images in a separate folder etc), you have to add these names to the first rule, separated by the | characters.

Now go to Settings-> Permalinks, change Common Settings to Custom Structure and enter what you wish it to look like.

Basically, once mod_rewrite is enabled on the lighttpd server, which is done by adding the following line to the lighttpd.conf file;

server.modules += ("mod_rewrite")

This should work for you too.