Non-www to www redirection

Keywords: WordPress - AWS - Technical issue - Secure Connections (SSL/HTTPS)

bndiagnostic ID: 4579aaf3-a3ee-5620-ad34-086a7604c867

bndiagnostic output:

? Apache: Found possible issues
? Resources: Found possible issues
? Php: Found possible issues
https://docs.bitnami.com/general/apps/wordpress/troubleshooting/debug-errors-apache/
https://docs.bitnami.com/bch/apps/moodle/troubleshooting/deny-connections-bots-apache/
https://docs.bitnami.com/installer/faq/linux-faq/administration/increase-memory-linux/
https://docs.bitnami.com/general/apps/wordpress/configuration/configure-phpfpm-processes/

bndiagnostic failure reason: The suggested guides are not related with my issue

Description:
Hi,

I tried redirecting my website from non-www to www by modifying the rules in /opt/bitnami/apache2/conf/bitnami/bitnami.conf file but it is not working. Would you be able to help me with the same?

Hi @moredatascientists ,

You are adding the “Rewrite” lines inside the <Directory "/opt/bitnami/apache2/htdocs"> block when they must be out of that block for Apache to redirect properly

<VirtualHost _default_:80>
 DocumentRoot "/opt/bitnami/apache2/htdocs"
 RewriteEngine On
 RewriteCond %{HTTP_HOST} !^(localhost|127.0.0.1)
 RewriteRule ^(.*)$ https://www.moredatascientists.com$1 [R=permanent,L]
  <Directory "/opt/bitnami/apache2/htdocs">
    Options Indexes FollowSymLinks
    AllowOverride All

Same for <VirtualHost _default_:443>

More info here: Access an application using only a single domain with Apache

Hi Jota,

Thank you for the prompt response. I have placed the code outside the <Directory “/opt/bitnami/apache2/htdocs”> but still it is not working.

Regards,
Manan

Can you run the bndiagnostic tool again?

Hi Jota,

Please find the ticket id

2d6002cb-0424-af54-2ed5-c1c02b45f683

I have modified a couple of files, but now the website is not running. It’s throwing

This site can’t be reached

The connection was reset.

Try:

ERR_CONNECTION_RESET

Could you help me with this??

Hi @moredatascientists ,

I do not know what changes you applied. The Diagnostic tool shows that the services were running before. The errors I can see in that package you sent are explained in this other post

Hi Jota,

Thank you for the prompt reply. While resolving Deny connections from bots/attackers using Apache

I am getting this error
AH00526: Syntax error on line 56 of /opt/bitnami/apache2/conf/bitnami/bitnami.conf:
SSLCertificateFile: file ‘/opt/bitnami/apache2/conf/server.crt’ does not exist or is empty

Hi @moredatascientists,

The SSLCertificateFile should point to the path where the site’s SSL certificates are placed, which seems to be /etc/letsencrypt/live/YOUR_DOMAIN.com/fullchain.pem

Regards,
Michiel

Hi Michiel,

The above problem is solved. The only problem I am facing is a redirection from non-www to www.

I have added an A record for moredatascientists and now I am getting an error

After adding the A record, this error is coming

403 ERROR
The request could not be satisfied.
Bad request. We can’t connect to the server for this app or website at this time. There might be too much traffic or a configuration error. Try again later, or contact the app or website owner.
If you provide content to customers through CloudFront, you can find steps to troubleshoot and help prevent this error by reviewing the CloudFront documentation.
Generated by cloudfront (CloudFront)
Request ID: oEk3ckmLSQeRSsNS4-ryjrFBxhIVHYQdUbELjRUlMr46HkQRtM4wFA==

and using the curl statement

bitnami@ip-172-26-1-72:~$ curl http://moredatascientists.com/

ERROR: The request could not be satisfied

403 ERROR

The request could not be satisfied.


Bad request. We can't connect to the server for this app or website at this time. There might be too much traffic or a configuration error. Try again later, or contact the app or website owner.
If you provide content to customers through CloudFront, you can find steps to troubleshoot and help prevent this error by reviewing the CloudFront documentation.

Generated by cloudfront (CloudFront)
Request ID: xj1p9Ouqdc78-SSrdp2LSzxXIwwdrC1YGPtgFCwo5Vla7ZFWbTHd5w==

Would you be able to help me with the same?