I have searched for quite sometime to get a solution or a hint to my query but didnt find anything valuable. Basically i have my application which is SSL secured. All i want is that
If users try to open the application without https and www, it should automatically append "
https://www
"If user enters "
https://mydomain.com
", it should change to "https://www.mydomain.com
"If user enters "
www.mydomain.com
", it should change to "https://www.mydomain.com
"
I understand this can be achieved through .htaccess but i am a lot ignorant about the way these files are written.
Any help will be highly appreciated.
Use the following:
Enable mod_rewrite and .htaccess through
httpd.conf
and then put this code in your.htaccess
underDOCUMENT_ROOT
directory:Try adding these rules to the htaccess file in your document root:
In your .htaccess file
RewriteCond %{HTTPS} off checks if HTTPS is off. If it is indeed off (the URL doesn't contain https://), then the rewrite rule applies and the user is redirected.