Blogs

redirect_https_http_htaccess_apache

  Apache: Redirect SSL except on mobile devices

Publicidad Google

Many SSL Certificate are not trusted with Android and other mobile devices giving NET::ERR_CERT_AUTHORITY_INVALID error.

To redirect SSL except on mobile devices, edit the Apache2 conf file for your domain, and add:

# Apache: Redirect SSL except on mobile devices

RewriteEngine on

RewriteCond  %{HTTP_USER_AGENT} "!android" [NC]
RewriteCond  %{HTTP_USER_AGENT} "!blackberry" [NC]
RewriteCond  %{HTTP_USER_AGENT} "!googlebot-mobile" [NC]
RewriteCond  %{HTTP_USER_AGENT} "!iemobile" [NC]
RewriteCond  %{HTTP_USER_AGENT} "!ipad" [NC]
RewriteCond  %{HTTP_USER_AGENT} "!iphone" [NC]
RewriteCond  %{HTTP_USER_AGENT} "!ipod" [NC]
RewriteCond  %{HTTP_USER_AGENT} "!opera mobile" [NC]
RewriteCond  %{HTTP_USER_AGENT} "!palmos" [NC]
RewriteCond  %{HTTP_USER_AGENT} "!webos" [NC]

RewriteRule     ^(.*)$ https://%{HTTP_HOST}/$1 [L,R]