1

I am pretty fresh to URL rewrites, and AWS for that matter. I installed Wordpress on an AWS EC2 micro instance and I would like to make is so that my site always redirects the www.domain.com to domain.com.

I followed the instruction from Bitnami here and the site is still accessible but it is still accessible from www.domain.com.

Here is the httpd-vhost.conf file:

<VirtualHost *:80>
    ServerName wordpress.example.com
    ServerAlias www.wordpress.example.com
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
    RewriteRule ^(.*)$ http://%1$1 [R=permanent,L]

    DocumentRoot "/opt/bitnami/apps/wordpress/htdocs"

    Include "/opt/bitnami/apps/wordpress/conf/httpd-app.conf"


</VirtualHost>

<VirtualHost *:443>
    ServerName wordpress.example.com
    ServerAlias www.wordpress.example.com
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
    RewriteRule ^(.*)$ https://%1$1 [R=permanent,L]
    DocumentRoot "/opt/bitnami/apps/wordpress/htdocs"
    SSLEngine on
    SSLCertificateFile "/opt/bitnami/apps/wordpress/conf/certs/server.crt"
    SSLCertificateKeyFile "/opt/bitnami/apps/wordpress/conf/certs/server.key"

    Include "/opt/bitnami/apps/wordpress/conf/httpd-app.conf"
</VirtualHost>

I have since rebooted the instance and nothing seems to change. Am I missing something?

I am very grateful for any help!

1 Answers1

0

I think that the problem is that you did not restart Apache after you applied your changes. Therefore, the new configuration is not loaded. I recommend you to execute the following command after you apply you changes:

sudo /opt/bitnami/ctlscript.sh restart apache

Please let us know if this solution works for you.

Best Regards,

Juan Ariza

Juan
  • 111
  • 1