• Our team is looking to connect with folks who use email services provided by Plesk, or a premium service. If you'd like to be part of the discovery process and share your experiences, we invite you to complete this short screening survey. If your responses match the persona we are looking for, you'll receive a link to schedule a call at your convenience. We look forward to hearing from you!
  • We are looking for U.S.-based freelancer or agency working with SEO or WordPress for a quick 30-min interviews to gather feedback on XOVI, a successful German SEO tool we’re looking to launch in the U.S.
    If you qualify and participate, you’ll receive a $30 Amazon gift card as a thank-you. Please apply here. Thanks for helping shape a better SEO product for agencies!
  • The BIND DNS server has already been deprecated and removed from Plesk for Windows.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS. We strongly recommend transitioning to Microsoft DNS within the next 6 weeks, before the Plesk 18.0.70 release.
  • The Horde component is removed from Plesk Installer. We recommend switching to another webmail software supported in Plesk.

Help with redirect to mobile site...

srkeith76

New Pleskian
I'm using Unity mobile to create a mobile site. This tool was an option in the web presence builder. I've tried to implement the PHP code that is generated through them to redirect mobile users to the mobile site but it is not working. When I put it in I just get a blank page, and not the mobile site. Can anyone help? Do I put the code site-wide or just in the home page?

Here is the code I'm using.

Code:
$nmpar = 'nomobile';
$nmpart = 'true';
$res = isset($_GET[$nmpar]) ? trim($_GET[$nmpar]) : '';
if (!empty($res) && strcasecmp($res, $nmpart) == 0) { setcookie($nmpar, $nmpart); }
else if (!isset($_COOKIE[$nmpar]) || strcasecmp($_COOKIE[$nmpar], $nmpart) != 0) {
    $mobile_site_url = 'http://mobi.inlandnwpc.com/';
    $is_mobile = false;    

    $browser = $_SERVER['HTTP_USER_AGENT'];
    $accept = $_SERVER['HTTP_ACCEPT'];

    if (isset($_SERVER['HTTP_X_WAP_PROFILE'])||isset($_SERVER['HTTP_PROFILE'])) {
        $is_mobile = true;
    } else if(preg_match('/(Alcatel|Asus|Android|BlackBerry|Ericsson|Fly|Huawei|i-mate|iPAQ|iPhone|iPod|LG-|LGE-|MDS_|MOT-|Nokia|Opera Mini|Opera Mobi|Palm|Panasonic|Pantech|Philips|Sagem|Samsung|Sharp|SIE-|Symbian|Vodafone|Voxtel|webOS|Windows CE|Windows Phone|ZTE-)/i',$browser)) {
        $is_mobile = true;
    } else if ((strpos($accept,'text/vnd.wap.wml')>0) || (strpos($accept,'application/vnd.wap.xhtml+xml')>0)) {
        $is_mobile = true;
    };

    if ($is_mobile)
       header('Location: ' . $mobile_site_url);
}

I've tried also adding <?php to the beginning of the code in the script. Any ideas on what I'm missing?
 
Hi,

Did you ever figure this out or get any kind of response outside this forum? I've been having a hell of a time trying to figure this out. The documentation does not provide any information. I have an open ticket with the support but they did not seem to understand the issue.
 
Nope, never got any response and never figured it out. I redid my website in wordpress and put a responsive theme on it. MUCH better.

Scott
 
Any ideas on what I'm missing?
Your code above will not work because it uses
header('Location: ' . $mobile_site_url);
You should use JS-redirects in such cases...

For php code you should use "<?php" prefix of course...


Did you ever figure this out or get any kind of response outside this forum? I've been having a hell of a time trying to figure this out. The documentation does not provide any information. I have an open ticket with the support but they did not seem to understand the issue.
If you want you can tell me ticket id (via PM) and I will check what was wrong there.

What kind of documentation did you searched for? You can leave a feedback about documentation at http://download1.parallels.net/WPB/...-installation-administration-guide/39588.htm#
 
The code must be inserted before any other scripts in order to execute. So just under the <HTML>; tag.
See this for an exmple http://us3.php.net/manual/en/function.header.php

When I move the code from where WPB puts it, and place it just under the &lt;HTML tag... it works. That's where this should be placed

So in for this site that we've been working on, it should look like this below, but the problem is, the code is inserted AFTER a bunch of other scripts and tags

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-GB" lang="en-GB">
<?PHP
$nmpar = 'nomobile';
$nmpart = 'true';
$res = isset($_GET[$nmpar]) ? trim($_GET[$nmpar]) : '';
if (!empty($res) && strcasecmp($res, $nmpart) == 0) { setcookie($nmpar, $nmpart); }
else if (!isset($_COOKIE[$nmpar]) || strcasecmp($_COOKIE[$nmpar], $nmpart) != 0) {
$mobile_site_url = 'http://mobile.domain.com/';
$is_mobile = false;

$browser = $_SERVER['HTTP_USER_AGENT'];
$accept = $_SERVER['HTTP_ACCEPT'];

if (isset($_SERVER['HTTP_X_WAP_PROFILE'])||isset($_SERVER['HTTP_PROFILE'])) {
$is_mobile = true;
} else if(preg_match('/(Alcatel|Asus|Android|BlackBerry|Ericsson|Fly|Huawei|i-mate|iPAQ|iPhone|iPod|LG-|LGE-|MDS_|MOT-|Nokia|Opera Mini|Opera Mobi|Palm|Panasonic|Pantech|Philips|Sagem|Samsung|Sharp|SIE-|Symbian|Vodafone|Voxtel|webOS|Windows CE|Windows Phone|ZTE-)/i',$browser)) {
$is_mobile = true;
} else if ((strpos($accept,'text/vnd.wap.wml')>0) || (strpos($accept,'application/vnd.wap.xhtml+xml')>0)) {
$is_mobile = true;
};

if ($is_mobile)
header('Location: ' . $mobile_site_url);
}

?>

<head>
 
This is for ticket #1859787

The code must be inserted before any other scripts in order to execute. So just under the <HTML> tag.
See this for an exmple http://us3.php.net/manual/en/function.header.php

The issue here is that Parallels and Unity Mobile are partners. You have to have some kind of working code here that will execute properly given the way that WPB inserts the code.

Unity Mobile says "use this code", but WPB does not place the code where it needs to be so that the HEADER value it adds is executed properly.

When I move the code from where WPB puts it, and place it just under the <HTML tag... it works. That's where this should be placed

before the <head

So in for this site that we've been working on, it should look like this:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-GB" lang="en-GB">
<?PHP
$nmpar = 'nomobile';
$nmpart = 'true';
$res = isset($_GET[$nmpar]) ? trim($_GET[$nmpar]) : '';
if (!empty($res) && strcasecmp($res, $nmpart) == 0) { setcookie($nmpar, $nmpart); }
else if (!isset($_COOKIE[$nmpar]) || strcasecmp($_COOKIE[$nmpar], $nmpart) != 0) {
$mobile_site_url = 'http://mobile.haterproofent.com/';
$is_mobile = false;

$browser = $_SERVER['HTTP_USER_AGENT'];
$accept = $_SERVER['HTTP_ACCEPT'];

if (isset($_SERVER['HTTP_X_WAP_PROFILE'])||isset($_SERVER['HTTP_PROFILE'])) {
$is_mobile = true;
} else if(preg_match('/(Alcatel|Asus|Android|BlackBerry|Ericsson|Fly|Huawei|i-mate|iPAQ|iPhone|iPod|LG-|LGE-|MDS_|MOT-|Nokia|Opera Mini|Opera Mobi|Palm|Panasonic|Pantech|Philips|Sagem|Samsung|Sharp|SIE-|Symbian|Vodafone|Voxtel|webOS|Windows CE|Windows Phone|ZTE-)/i',$browser)) {
$is_mobile = true;
} else if ((strpos($accept,'text/vnd.wap.wml')>0) || (strpos($accept,'application/vnd.wap.xhtml+xml')>0)) {
$is_mobile = true;
};

if ($is_mobile)
header('Location: ' . $mobile_site_url);
}

?>

<head>
 
I've got customers using Parallels Web Presence Builder (WPB) which is a tool that helps you design web sites. They don't have direct access to the files. It's a front end for building the web site. They have a partnership with Unity Mobile. With Unity Mobile, you can build mobile friendly web sites.

So you build your main web site using WPB, then hit a button in the control panel that kicks you out to Unity Mobile where you build your mobile version. Unity Mobile provides some code to insert in the main site that is supposed to provide redirection for mobile devices. You browse from your phone or tablet to the main site, this code is supposed to execute, redirecting you to the mobile site.

Only, the code provided by Unity Mobile does not work given where WPB places the code in the page. So I'm looking for alternative methods of redirection.

So the code they provide should be inserted just under the opening HTML tag, before any other scripts execute. The Problem is that WPB places it much further down where the HTTP header that PHP tries adding does not work. Can anyone provide an alternative method that would work given where WPB places the code?


This is what the code should look like if placed correctly:

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-GB" lang="en-GB">
<?PHP
$nmpar = 'nomobile';
$nmpart = 'true';
$res = isset($_GET[$nmpar]) ? trim($_GET[$nmpar]) : '';
if (!empty($res) && strcasecmp($res, $nmpart) == 0) { setcookie($nmpar, $nmpart); }
else if (!isset($_COOKIE[$nmpar]) || strcasecmp($_COOKIE[$nmpar], $nmpart) != 0) {
$mobile_site_url = 'http://mobile.domain.com/';
$is_mobile = false; 

$browser = $_SERVER['HTTP_USER_AGENT'];
$accept = $_SERVER['HTTP_ACCEPT'];

if (isset($_SERVER['HTTP_X_WAP_PROFILE'])||isset($_SERVER['HTTP_PROFILE'])) {
$is_mobile = true;
} else if(preg_match('/(Alcatel|Asus|Android|BlackBerry|Ericsson|Fly|Huawei|i-mate|iPAQ|iPhone|iPod|LG-|LGE-|MDS_|MOT-|Nokia|Opera Mini|Opera Mobi|Palm|Panasonic|Pantech|Philips|Sagem|Samsung|Sharp|SIE-|Symbian|Vodafone|Voxtel|webOS|Windows CE|Windows Phone|ZTE-)/i',$browser)) {
$is_mobile = true;
} else if ((strpos($accept,'text/vnd.wap.wml')>0) || (strpos($accept,'application/vnd.wap.xhtml+xml')>0)) {
$is_mobile = true;
};

if ($is_mobile)
header('Location: ' . $mobile_site_url);
}

?>

<head>


This is what WPB actually does, placing it much further down:

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-GB" lang="en-GB">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<title>Home - Site Name</title>
	<meta name="description" content="Some description here" /><meta name="keywords" content="some,keywords,here" /><meta name="generator" content="Parallels Web Presence Builder 11.0.10" />
	<link rel="stylesheet" type="text/css" href="../css/style.css?template=generic" />
	<!--[if IE 7]>
		<link rel="stylesheet" type="text/css" href="../css/ie7.css?template=generic" />
	<![endif]-->
	<script language="JavaScript" type="text/javascript" src="../js/style-fix.js"></script>
	<script language="JavaScript" type="text/javascript" src="../js/css_browser_selector.js"></script>
	<link type="text/css" href="../css/header-8b8528d2-66b4-12cd-ab1c-0aedf2d1d468.css?template=generic" rel="stylesheet" />
<link type="text/css" href="../css/navigation-a0049a57-79e8-aea6-d77b-1ab78d7146f2.css?template=generic" rel="stylesheet" />
<!--[if IE]><style type="text/css"></style><![endif]--><style type="text/css">#watermark {-webkit-border-radius:10px 10px 10px 10px;-moz-border-radius:10px 10px 10px 10px;border-radius:10px 10px 10px 10px;}
.content {-webkit-border-radius:10px 10px 10px 10px;-moz-border-radius:10px 10px 10px 10px;border-radius:10px 10px 10px 10px;}
.column1 {-webkit-border-radius:10px 10px 10px 10px;-moz-border-radius:10px 10px 10px 10px;border-radius:10px 10px 10px 10px;}
.column2 {-webkit-border-radius:10px 10px 10px 10px;-moz-border-radius:10px 10px 10px 10px;border-radius:10px 10px 10px 10px;}
.header {-webkit-border-radius:0 0 10px 10px;-moz-border-radius:0 0 10px 10px;border-radius:0 0 10px 10px;}
.footer {-webkit-border-radius:10px 10px 10px 10px;-moz-border-radius:10px 10px 10px 10px;border-radius:10px 10px 10px 10px;}
#content .container-content-inner {padding-bottom: 10px}
#content .container-content-inner {padding-top: 10px}
#column1 .container-content-inner {padding-bottom: 10px}
#column1 .container-content-inner {padding-top: 10px}
#column2 .container-content-inner {padding-bottom: 10px}
#column2 .container-content-inner {padding-top: 10px}
#header .widget-header:last-child .widget-content{-webkit-border-bottom-right-radius: 10px;-moz-border-radius-bottomright: 10px;border-bottom-right-radius: 10px;-webkit-border-bottom-left-radius: 10px;-moz-border-radius-bottomleft: 10px;border-bottom-left-radius: 10px;}
#header .widget-navigation .widget-content {padding-right: 10px}
#header .widget-navigation .widget-content {padding-left: 10px}
#footer .widget-navigation .widget-content {padding-right: 10px}
#footer .widget-navigation .widget-content {padding-left: 10px}
</style><script type="text/javascript" src="../components/jquery/jquery.min.js?ac=11.0.10_38713.12081600"></script>
<script type="text/javascript" src="../js/helpers.js?ac=11.0.10_38713.12081600"></script>
<link rel="shortcut icon" href="../favicon.ico?1394043840">
<script type="text/javascript">var siteBuilderJs = jQuery.noConflict(true);</script><script type="text/javascript">siteBuilderJs.startFixHeightColumns();</script><script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-48157946-1', 'domain.com');
  ga('send', 'pageview');

</script>



</head>
<body id="template" class="">
	<div class="site-frame">
		<div id="wrapper" class="container-content external-border-none ">
	<div class="external-top"><div><div><div><div></div></div></div></div></div>
	<div class="external-side-left">
		<div class="external-side-left-top">
			<div class="external-side-left-bottom">
				<div class="external-side-right">
					<div class="external-side-right-top">
						<div class="external-side-right-bottom">
							<div id="watermark" class="pageContentText  border-none">
								<div id="watermark-content" class="container-content">
									<div id="layout"><div id="header" class="header border-none">
	<div id="header-top" class="top"><div><div></div></div></div>
	<div id="header-side" class="side"><div id="header-side2" class="side2">
		<div class="container-content">
			<div id="header-content">
				<div class="container-content-inner" id="header-content-inner">
	<div class="widget widget-script" id="widget-facfbce9-46a4-bf01-1e63-39302f8f3dd8">
			<div class="widget-content"><?PHP
$nmpar = 'nomobile';
$nmpart = 'true';
$res = isset($_GET[$nmpar]) ? trim($_GET[$nmpar]) : '';
if (!empty($res) && strcasecmp($res, $nmpart) == 0) { setcookie($nmpar, $nmpart); }
else if (!isset($_COOKIE[$nmpar]) || strcasecmp($_COOKIE[$nmpar], $nmpart) != 0) {
    $mobile_site_url = 'http://mobile.domain.com/';
    $is_mobile = false;    

    $browser = $_SERVER['HTTP_USER_AGENT'];
    $accept = $_SERVER['HTTP_ACCEPT'];

    if (isset($_SERVER['HTTP_X_WAP_PROFILE'])||isset($_SERVER['HTTP_PROFILE'])) {
        $is_mobile = true;
    } else if(preg_match('/(Alcatel|Asus|Android|BlackBerry|Ericsson|Fly|Huawei|i-mate|iPAQ|iPhone|iPod|LG-|LGE-|MDS_|MOT-|Nokia|Opera Mini|Opera Mobi|Palm|Panasonic|Pantech|Philips|Sagem|Samsung|Sharp|SIE-|Symbian|Vodafone|Voxtel|webOS|Windows CE|Windows Phone|ZTE-)/i',$browser)) {
        $is_mobile = true;
    } else if ((strpos($accept,'text/vnd.wap.wml')>0) || (strpos($accept,'application/vnd.wap.xhtml+xml')>0)) {
        $is_mobile = true;
    };

    if ($is_mobile)
       header('Location: ' . $mobile_site_url);
}
?></div>
		</div>

	<div class="wi
 
It's not possible to put any custom code before opening <html> tag in WPB but you can use another JS-solution.
As I can see your code it's just a check for mobile device and redirect them onto separate url.

You can find a lot of such solutions. One of variants I've found at http://detectmobilebrowsers.com
To integrate it to your WPB site just download Javascript version and place it at Settings/Advanced -> Edit Metadata:
Code:
<script type="text/javascript">
(function(a,b){if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0,4)))window.location=b})(navigator.userAgent||navigator.vendor||window.opera,'http://detectmobilebrowser.com/mobile');
</script>
Of course you should replace 'http://detectmobilebrowser.com/mobile' with your URL and republish site.

I've checked at my Opera for android. It works like a charm.
 
About UnityMobile...
MichaelCa, why do you expect that UnityMobile should work with WPB? It's 2 different products.
WPB have own mobile optimizations and there are no reasons to use UnityMobile for WPB sites for most people.
 
Back
Top