0

I have a little problem and I don't know why is that.

I tried :

RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

and

RewriteCond %{HTTP_HOST} ^domain.com [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]

But no succes.

It redirect the website from : http://domain.com to http://www.domain.com but not from http://domain.com/sample-page to http://www.domain.com/sample-page

Why?!

Update : I use HHVM 3.6.6 . This can be the reason?! And place for .htaccess is in httpd-app.conf (Bitnami HHVM)

Alexcsandru
  • 387
  • 3
  • 9
  • 1
    Possible duplicate of [Redirect non-www to www in .htaccess](http://stackoverflow.com/questions/12050590/redirect-non-www-to-www-in-htaccess) – Maximillian Laumeister Oct 03 '15 at 22:16
  • It might be a duplicate, but that one was for the case where the questioner left out a trailing slash – Foon Oct 03 '15 at 22:29
  • There is no duplicate of Redirect non-www to www. Right now this code is active. **RewriteCond %{HTTP_HOST} !^www\. RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]** – Alexcsandru Oct 04 '15 at 05:03

1 Answers1

0

Bitnami developer here.

If you want to apply this redirection by default, you can add it in the default VirtualHost in the "installdir/apache2/conf/bitnami/bitnami.conf" file.

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

<VirtualHost *:443>
  ServerName app.example.com
  ServerAlias www.app.example.com
  RewriteEngine On
  RewriteCond %{HTTP_HOST} !^www\. [NC]
  RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
 ...

Please note that you will need to restart Apache to apply the changes.

installdir/ctlscript.sh restart

You can learn more about how to configure Apache using this link.

https://wiki.bitnami.com/Components/Apache

I hope it helps.

Jota

Jota Martos
  • 4,548
  • 3
  • 12
  • 20