Error Redirect custom domains to the Apache server (from www. to non www.)

Keywords: WordPress - Google Cloud Platform - Technical issue - Services (Apache, MariaDB, MySQL…)

bndiagnostic ID: 8ff8e2ab-75bb-b259-d8be-6daec0c63ccb

bndiagnostic output:

? Apache: Found possible issues


I need to redirect version to

I followed this post

I changed /opt/bitnami/apache2/conf/vhosts/wordrpress-vhost.conf file adding:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.(.)$ [NC]
RewriteRule ^(.
)$ http://%1$1 [R=permanent,L]

And changed /opt/bitnami/apache2/conf/vhosts/wordpress-https-vhost.conf file adding:

RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1$1 [R=permanent,L]

When I go to , it works and redirects to

The problem is when I go to , redirections fails because the ulr changes to mydomain.comany-other-url

I can not find the problem. Please, can you help me? Thank you.

Hi @dagalar,

Edit both “RewriteRule” lines and insert one “/” character between %1 and $1.

RewriteRule ^(.*)$ http://%1/$1 [R=permanent,L]
RewriteRule ^(.*)$ https://%1/$1 [R=permanent,L]

You will need to restart Apache for the changes to take effect.

Happy to help!

Was my answer helpful? Click on :heart:

Hi @jota,

Thank you, it works!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.