Apache rewrite redirect to https and www
Posted
by
Jo Erlang
on Server Fault
See other posts from Server Fault
or by Jo Erlang
Published on 2012-09-11T04:39:02Z
Indexed on
2012/09/11
9:40 UTC
Read the original article
Hit count: 334
I need to get mod_rewrite to do the following
http://abc.com -> https://www.abc.com
https://abc.com/login -> https://www.abc.com/login
http://www.abc.com?x=3 -> https://www.abc.com?x=3
https://abc.com/login?x=1 -> https://www.abc.com/login?x=1
http://www.abc.com/login?x=3 -> https://www.abc.com/login
I have the following, in my abc.com.conf vhost file but its not work correctly
<VirtualHost *:80>
ServerName abc.com
ServerAlias www.abc.com
RewriteCond %{HTTP_HOST} ^abc\.com
RewriteRule ^(.*)$ https://www.abc.com/$1 [R=permanent,L]
RewriteCond %{HTTPS} off
RewriteRule (.*) https://www.abc.com/%{REQUEST_URI}
</VirtualHost>
<VirtualHost *:443>
ServerName abc.com
ServerAlias www.abc.com
RewriteCond %{HTTP_HOST} ^abc\.com
RewriteRule ^(.*)$ https://www.abc.com/$1 [R=permanent,L]
</VirtualHost>
Can anyone help me out on the rest?
[edited to clarify]
© Server Fault or respective owner