<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>force ssl on Tutes Club</title><link>https://tutes.in/tag/force-ssl/</link><description>Recent content in force ssl on Tutes Club</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Wed, 21 Feb 2018 17:45:20 +0000</lastBuildDate><atom:link href="https://tutes.in/tag/force-ssl/index.xml" rel="self" type="application/rss+xml"/><item><title>Forcing website to https and www using htaccess on apache servers</title><link>https://tutes.in/forcing-website-to-https-and-www-using-htaccess-on-apache-servers/</link><pubDate>Wed, 21 Feb 2018 17:45:20 +0000</pubDate><guid>https://tutes.in/forcing-website-to-https-and-www-using-htaccess-on-apache-servers/</guid><description>&lt;p&gt;To first force HTTPS, you must check the correct environment variable %{HTTPS} off, but your rule above then prepends the www. Since you have a second rule to enforce www., don’t use it in the first rule.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;RewriteCond %{HTTPS} off
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# First rewrite to HTTPS:
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Don&amp;#39;t put www. here. If it is already there it will be included, if not
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# the subsequent rule will catch it.
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Now, rewrite any request to the wrong domain to use www.
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# [NC] is a case-insensitive match
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;RewriteCond %{HTTP_HOST} !^www\. [NC]
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description></item></channel></rss>