I have a subdomain set up (http://subdomain.domain.com) and i want all requests to this should be redirected to httpS://subdomain.domain.com. I tried the following:
- Code: Select all
#
RewriteEngine on
RewriteCond %{SERVER_PORT} ^80$
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
#
Now if I visit http://subdomain.domain.com, it shows me the page but without being redirected to httpS.
I also tried replacing the above condition with the following:
- Code: Select all
RewriteCond %{SERVER_PORT} !^443$
No difference.
Another important thing. If I try to
- Code: Select all
echo $_SEVER['SERVER_PORT']
Is there any other way to detect if the browser address is http so that it can be redirected to https?
Thanks.