Apache2 re-direct help.
by wh33t from LinuxQuestions.org on (#50581)
Hey LQ,
Is anyone able to explain to me why the following does not work:
Code:<VirtualHost *:80>
ServerName www.domain.com
RewriteEngine on
RewriteCond %{SERVER_NAME} =domain.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>I am simply trying to make it so the user is always forwarded from http://www.domain.com to https://domain.com
When I say it doesn't work, what ends up happening is that Apache ignores the .conf and just serves the default /var/www/html/index.html file and doesn't rewrite the url at all.
FYI, the SSL does work.


Is anyone able to explain to me why the following does not work:
Code:<VirtualHost *:80>
ServerName www.domain.com
RewriteEngine on
RewriteCond %{SERVER_NAME} =domain.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>I am simply trying to make it so the user is always forwarded from http://www.domain.com to https://domain.com
When I say it doesn't work, what ends up happening is that Apache ignores the .conf and just serves the default /var/www/html/index.html file and doesn't rewrite the url at all.
FYI, the SSL does work.