WordPress Multisite on AWS LightSail, want to redirect www URL's to non-www URL's

Keywords: WordPress Multisite - AWS - How to - Other
Description:
I am trying to modify the apache configuration file to automatically redirect
from www to non-www URLs. I’d also like to automatically redirect http to https. And, I’d like to make this work for my main domain (tws-west.org) and the subdomains (hawaii, virtual2021, etc.)
I have followed Bitnami instructions and the https redirection seems to be working for my subdomains but not my main domain.
I have attempted other changes to redirect www addresses, but that does not seem to be working. I’ve run the bnsupport-tool, and I have a zip file to upload.

Hello @eric.renger,

I have checked your main domain and the created certificate is only valid for your non-www domains. To have www to non-www redirection working, you need to include the www domains in the certificate.

Regarding the issue with HTTPS redirection, you can upload the .zip file you the file-sharing service of your choice and share with me the link via private message.

Regards,
Francisco de Paz

I generated the SSL certificate with the bncert tool, and it seemed to fail when I tried to include the www.* names in the list of domains. Does the bncert tool work with the WordPress multisite setup? I have the main site, several subdomains, and then another WP site in the multisite installation that has a completely separate domain name.

I have not used this support system before, so I’m not sure how to share the link to the zip file in my Google Drive with you. Is this a private message, or is this visible to everyone?

thanks,
Eric

Hello @eric.renger,

We are aware that bncert-tool has limitations and there are cases like the one you are explaining where it’s better to use the alternative approach https://docs.bitnami.com/aws/how-to/generate-install-lets-encrypt-ssl/#alternative-approach

This thread is public, please follow the steps detailed in this guide’s section Manually Upload The Bitnami Support Tool Bundle to send me the link privately.

Regards,
Francisco de Paz

I have sent you a link to the .zip file.

thanks,
Eric

I followed the steps for using the lego tool to generate the Lets Encrypt SSL certificate, but I encountered an error during the first step: I got errors like this:
[www.tws-west.org] acme: error: 400 :: urn:ietf:params:acme:error:dns :: DNS problem: NXDOMAIN looking up A for www.tws-west.org - check that a DNS record exists for this domain
In my LightSail DNS zone for this domain, I have A record entries for the main domain and each subdomain. Do I need to create additional A records for the primary domain and each subdomain with the www. prepended to the URL? Also, do I need to remove the existing SSL certificate before generating the new certificate that will include the www.*** addresses?

thanks,
Eric

Hello @eric.renger,

It is as you say, you need to tell your DNS that the www. domains also point to your instance’s IP. Instead of creating an A record for each www domain, you can make use of a CNAME record. You can find information on how to do so here: https://www.godaddy.com/help/add-a-cname-record-19236

Regards,
Francisco de Paz

hi @fdepaz,
I have add CNAME records for the www. URLs, and everything seems to redirect correctly from www. to the non-www URL and from http to https for all the subdomains, but my main domain still won’t redirect from http to https. I wonder if it is a setting in WordPress? For all the subdomains, I have changed the site address URL to https://…, but for the main domain, the site address URL is grayed out and I cannot change it.

Hello @eric.renger,

Could you please check our guide on how to Force HTTPS Redirection With Apache? Also, it seems the link you shared with me via private message has the access restricted; I have sent you a request. Please share with me a new support tool .zip if the automatic upload is still failing.

Regards,
Francisco de Paz

that link to the HTTPS redirection was the last piece of information I needed, and I think I have everything working the way I want now. Thanks for all your help.

Hello @eric.renger,

I’m glad you could get it working! I’ll be closing this thread. If you have any other issues in the future, do not doubt to get in contact with us :grinning:

Regards,
Francisco de Paz