Home How to redirect all traffics to HTTPS only EXCEPT mobile and subdomains?
Reply: 0

How to redirect all traffics to HTTPS only EXCEPT mobile and subdomains?

user3243499
1#
user3243499 Published in 2017-11-14 09:15:56Z

The .htaccess file that I am using now is:

#Force www:
RewriteEngine On

RewriteCond %{HTTP_USER_AGENT} "!(android|blackberry|googlebot-mobile|iemobile|ipad|iphone|ipod|opera mobile|palmos|webos)" [NC]
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule ^$ http://www.example.com/ [L,R=302]


RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://www.%1%{REQUEST_URI} [L,NE,R=301]

However, when I tested using my mobile I found that it is redirecting to the https only and also while accessing any subdomains it redirects to the https.

Am I doing something wrong in my htaccess script?

Thanks in advance.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.301994 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO