0

I have a problem with my bitnami wordpress hosted on Google cloud. I have both the www and the non-www version running in parallel. I want to have all the non-www traffic 301 to the www version.

I added these lines into the conf file:

    RewriteEngine On
    RewriteCond %{HTTPS} !=on
    RewriteRule ^/(.*) https://example.com/$1 [L,R=301]

But it does not fix the issue. Anyone has a solution?

Armando Cuevas
  • 233
  • 1
  • 15
Roma
  • 1

1 Answers1

1

Bitnami Engineer here,

To redirect all the requests to the www domain, you can make the following changes in the /opt/bitnami/apache2/conf/bitnami/bitnami.conf

<VirtualHost _default_:80>
RewriteEngine On
RewriteCond %{HTTP_HOST} !^(localhost|127.0.0.1)
RewriteRule ^(.*)$ https://www.example.com$1 [R=301,L]
...

<VirtualHost _default_:443>
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.example.com$
RewriteCond %{HTTP_HOST} !^(localhost|127.0.0.1)
RewriteRule ^(.*)$ https://www.example.com$1 [R=301,L]
...

and restart Apache

sudo /opt/bitnami/ctlscript.sh restart apache

More information here: https://docs.bitnami.com/google/apps/wordpress/administration/use-single-domain/

Jota Martos
  • 301
  • 1
  • 4