Title: Plugin switches to https when changing between mobile and standard view
Last modified: August 20, 2016

---

# Plugin switches to https when changing between mobile and standard view

 *  [omega1](https://wordpress.org/support/users/gavinwatson/)
 * (@gavinwatson)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/plugin-switches-to-https-when-changing-between-mobile-and-standard-view/)
 * Hello!
 * I have noticed that on two of the websites I have installed this plugin on when
   switching betweenmmobile and standard view the plugin switches to https:// instead
   of http:// and therefore thrown up an error.
 * How do I stop it trying to go https:// ?
 * Thanks in advance!
 * [http://wordpress.org/extend/plugins/wptouch/](http://wordpress.org/extend/plugins/wptouch/)

Viewing 15 replies - 1 through 15 (of 26 total)

1 [2](https://wordpress.org/support/topic/plugin-switches-to-https-when-changing-between-mobile-and-standard-view/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/plugin-switches-to-https-when-changing-between-mobile-and-standard-view/page/2/?output_format=md)

 *  [Ron Whitler](https://wordpress.org/support/users/ron-whitler/)
 * (@ron-whitler)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/plugin-switches-to-https-when-changing-between-mobile-and-standard-view/#post-3228934)
 * I’m having the same problem.
 * The URL in question is [http://leveraging.us](http://leveraging.us)
 * The mobile site loads correctly, but when I flip the switch to go to turn off
   the mobile theme, the URL loads as “https” and doesn’t load.
 * If I manually load the non-mobile page and then flip the switch back to mobile,
   the “s” is added to http and it doesn’t load.
 * I’m on a self hosted network – WP v 3.4.2 – the other 4 blogs on my network do
   not have this problem. They switch fine.
 * I’m using the plugin WordPress MU Domain Mapping V 0.5.4.2 to map the domain 
   leveraging.us onto my installation.
 * These 2 threads seem to reference the same issue:
 * [http://wordpress.org/support/topic/plugin-wptouch-how-to-turn-off-https?replies=7](http://wordpress.org/support/topic/plugin-wptouch-how-to-turn-off-https?replies=7)
 * [http://wordpress.org/support/topic/plugin-wptouch-error-404-when-changing-to-desktop-site?replies=6](http://wordpress.org/support/topic/plugin-wptouch-error-404-when-changing-to-desktop-site?replies=6)
 * Thanks for any help you can give.
 *  [BraveNewCode Inc.](https://wordpress.org/support/users/bravenewcode/)
 * (@bravenewcode)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/plugin-switches-to-https-when-changing-between-mobile-and-standard-view/#post-3228975)
 * Hi gavinwatson,
 * Do you have any ssl-based plugins or setups going on on your website at all?
 * Same question for you Ron. What’s the difference between the site you’re seeing
   this issue on and the rest of the sites in your multisite network?
 *  Thread Starter [omega1](https://wordpress.org/support/users/gavinwatson/)
 * (@gavinwatson)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/plugin-switches-to-https-when-changing-between-mobile-and-standard-view/#post-3228976)
 * Hi, thanks for responding.
 * No, I have no ssl-based plugins, I do not run multisite either.
 * Thanks
 *  [BraveNewCode Inc.](https://wordpress.org/support/users/bravenewcode/)
 * (@bravenewcode)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/plugin-switches-to-https-when-changing-between-mobile-and-standard-view/#post-3228977)
 * Thanks for the info there gavinwatson. Please share the URL of at least one of
   the website in question and we’ll be happy to take a look for you. Also, what
   device are you using to test?
 *  Thread Starter [omega1](https://wordpress.org/support/users/gavinwatson/)
 * (@gavinwatson)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/plugin-switches-to-https-when-changing-between-mobile-and-standard-view/#post-3228978)
 * [http://www.canariesnews.com](http://www.canariesnews.com)
    [http://www.canariestelecom.com](http://www.canariestelecom.com)
 * I’m using a Samsung Galaxy SIII
 * Thanks
 *  [Ron Whitler](https://wordpress.org/support/users/ron-whitler/)
 * (@ron-whitler)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/plugin-switches-to-https-when-changing-between-mobile-and-standard-view/#post-3228980)
 * >>What’s the difference between the site you’re seeing this issue on and the 
   rest of the sites in your multisite network?
 * The only difference between the one that’s not working and the ones that are 
   seems to be the Domain Mapping plugin
 * here are some blogs on my network that work:
    [http://celiamusic.net](http://celiamusic.net)
   [http://blog.celiamusic.net](http://blog.celiamusic.net) [http://tanner.celiamusic.net](http://tanner.celiamusic.net)
   [http://ron.celiamusic.net](http://ron.celiamusic.net)
 * the one that doesn’t work is [http://leveraging.us](http://leveraging.us) — it’s
   domain mapped to [http://leverage.celiamusic.net](http://leverage.celiamusic.net)
 * using the plugin: WordPress MU Domain Mapping – Version 0.5.4.2
 * WordPress is current – 3.4.2
 * I’m having the issue on iphone with current software and droid.
 * The message I’m receiving is “unable to establish a secure connection.”
 * Turning the mobile theme off attempts to establish the connection via https (
   the same thing happens coming from standard to mobile version)
 *  [Jacquesdancona](https://wordpress.org/support/users/jacquesdancona/)
 * (@jacquesdancona)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/plugin-switches-to-https-when-changing-between-mobile-and-standard-view/#post-3228985)
 * I’ve noticed we’re having the same problem. Desktop mode redirects to https instead
   of http. We’re not using any cache plugins at this moment and we do not use plugins
   related to ssl.
 *  [Jacquesdancona](https://wordpress.org/support/users/jacquesdancona/)
 * (@jacquesdancona)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/plugin-switches-to-https-when-changing-between-mobile-and-standard-view/#post-3228986)
 * Quick dirty fix is to edit line 554 of wptouch.php to
 *     ```
       $protocol = ( !empty($_SERVER['HTTPS']) ) ? 'http://' : 'http://';
       ```
   
 * BraveNewCode Inc.,
 * it’s late over here in the Netherlands, I’m sleepy and already in bed so forgive
   me if I make any mistakes.
 * Using empty() with $_SERVER[‘HTTPS’] here isn’t going to work for some users 
   because
 * >  **$_SERVER[‘HTTPS’]**
   >  Note: Note that when using ISAPI with IIS, the value
   > will be **off** if the request was not made through the HTTPS protocol.
 *  [Source](http://php.net/manual/en/reserved.variables.server.php)
 * ‘Off’ is what I get when I echo $_SERVER[‘HTTPS’].
 *  [Jacquesdancona](https://wordpress.org/support/users/jacquesdancona/)
 * (@jacquesdancona)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/plugin-switches-to-https-when-changing-between-mobile-and-standard-view/#post-3228987)
 * This seems to do the trick without forcing $protocol to use [http://](https://wordpress.org/support/topic/plugin-switches-to-https-when-changing-between-mobile-and-standard-view/?output_format=md),
   
   change line 554 of wptouch.php to:
 *     ```
       $protocol = ( !empty($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'off' ) ? 'https://' : 'http://';
       ```
   
 * I’m not sure about this though. Use it your own risk 🙂
 *  [BraveNewCode Inc.](https://wordpress.org/support/users/bravenewcode/)
 * (@bravenewcode)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/plugin-switches-to-https-when-changing-between-mobile-and-standard-view/#post-3228988)
 * Because this is not a widely reported issue, we are speculating that there is
   something else in common with the sites in question where this occurs. Perhaps
   you happen to be using the same desktop theme or themes from the same developer?
   Until we can reproduce the issue here, we really haven’t a way to test what’s
   happening for you so as much information about your individual WordPress configurations(
   themes and plugins) from all affected is helpful.
 * [@jacquesdancona](https://wordpress.org/support/users/jacquesdancona/), thank
   you for sharing your solution. Hopefully it is helpful to others experiencing
   this issue until it’s isolated and address on our end.
 *  [Jacquesdancona](https://wordpress.org/support/users/jacquesdancona/)
 * (@jacquesdancona)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/plugin-switches-to-https-when-changing-between-mobile-and-standard-view/#post-3228989)
 * I’m wrong about my fix and I need to be sleeping. Last thing I found with help
   from [here](http://stackoverflow.com/questions/1175096/how-to-find-out-if-you-are-using-https-without-serverhttps):
 *     ```
       if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off'
           || $_SERVER['SERVER_PORT'] == 443) {
   
           $protocol = "https://";
       } else {
          $protocol = "http://";
       }
       ```
   
 *  Thread Starter [omega1](https://wordpress.org/support/users/gavinwatson/)
 * (@gavinwatson)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/plugin-switches-to-https-when-changing-between-mobile-and-standard-view/#post-3228990)
 * On from what Jacquesdancona has written, I also decided to take a look at this
   and I found in this code from wptouch.php (inside the wptouch folder within the
   plugins folder):
 *     ```
       function bnc_check_switch_redirect() {
       		if ( isset( $_GET['wptouch_redirect'] ) ) {
       			if ( isset( $_GET['wptouch_redirect_nonce'] ) ) {
       				$nonce = $_GET['wptouch_redirect_nonce'];
       				if ( !wp_verify_nonce( $nonce, 'wptouch_redirect' ) ) {
       					_e( 'Nonce failure', 'wptouch' );
       					die;
       				}
   
       				$protocol = ( !empty($_SERVER['HTTPS']) ) ? 'https://' : 'http://';
       				$redirect_location = $protocol . $_SERVER['SERVER_NAME'] . $_GET['wptouch_redirect'];
   
       				header( 'Location: ' . $redirect_location );
       				die;
       			}
       		}
       	}
       ```
   
 * If you change this line FROM:
 * `$protocol = ( !empty($_SERVER['HTTPS']) ) ? 'https://' : 'http://';`
 * TO this :
 * `$protocol = ( !empty($_SERVER['HTTPS']) ) ? 'http://' : 'http://';`
 * (removed the ‘s’ from https)
 * It all seems to work fine.
 * Unfortunately, I don’t know what other effects this may have! But it worked for
   me.
 *  Thread Starter [omega1](https://wordpress.org/support/users/gavinwatson/)
 * (@gavinwatson)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/plugin-switches-to-https-when-changing-between-mobile-and-standard-view/#post-3228991)
 * Hi, sorry, I have just realised that my solution is exactly the same as the one
   already provided!
 * I’m not sure why the original solution (which is the same as what I did) is not
   sufficient? Will it have any other effect that I should be worried about??
 * Thanks
 *  [Jacquesdancona](https://wordpress.org/support/users/jacquesdancona/)
 * (@jacquesdancona)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/plugin-switches-to-https-when-changing-between-mobile-and-standard-view/#post-3228992)
 * Hi Gavin,
 * That’s what I tried to explain in my quick dirty fix post (4 posts back 😉 ).
 * This will work for you because you’re forcing it to use ‘[http://&#8217](http://&#8217);.
   
   If you don’t use https in any way this won’t result (I think) in any problems.
   However, if you update WPtouch the edit will be overwritten with a new wptouch.
   php.
 * The problem does not seem to be theme or plugin related because I did a fresh
   install yesterday (default Twenty Twelve theme) with only WPTouch installed and
   the problem still occurs. I’ve already tested this three WordPress installs on
   two Microsoft-IIS/6.0 systems (one VPS and one shared hosting account).
 * I’m currently emailing with Brave New Code and they have access to these WP installs.
   They’ll probably check today.
 * By the way, thanks for the quick support and emails, Brave New Code!
 *  [BraveNewCode Inc.](https://wordpress.org/support/users/bravenewcode/)
 * (@bravenewcode)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/plugin-switches-to-https-when-changing-between-mobile-and-standard-view/#post-3228993)
 * We’ve had a look at [@jacquesdancona](https://wordpress.org/support/users/jacquesdancona/)’
   s setup and can reproduce the error though, still, not in any of our development
   environment setups. That leads us to suspect his server setup. There may be server-
   side commonalities among those experiencing the issue. We recommend reporting
   the issue to your host to see what they can track down for you.

Viewing 15 replies - 1 through 15 (of 26 total)

1 [2](https://wordpress.org/support/topic/plugin-switches-to-https-when-changing-between-mobile-and-standard-view/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/plugin-switches-to-https-when-changing-between-mobile-and-standard-view/page/2/?output_format=md)

The topic ‘Plugin switches to https when changing between mobile and standard view’
is closed to new replies.

 * ![](https://ps.w.org/wptouch/assets/icon-256x256.png?rev=1313960)
 * [WPtouch - Make your WordPress Website Mobile-Friendly](https://wordpress.org/plugins/wptouch/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wptouch/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wptouch/)
 * [Active Topics](https://wordpress.org/support/plugin/wptouch/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wptouch/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wptouch/reviews/)

## Tags

 * [HTTP](https://wordpress.org/support/topic-tag/http/)
 * [HTTPS](https://wordpress.org/support/topic-tag/https/)
 * [switching](https://wordpress.org/support/topic-tag/switching/)

 * 26 replies
 * 5 participants
 * Last reply from: [Sperry77](https://wordpress.org/support/users/sperry77/)
 * Last activity: [13 years ago](https://wordpress.org/support/topic/plugin-switches-to-https-when-changing-between-mobile-and-standard-view/page/2/#post-3229015)
 * Status: not resolved