This help center supports the Legacy platform Dudamobile. As of April 1st, 2019 new sites cannot be created, existing sites will remain live with the same functionality and editor access.

Email support and phone support (for Duda customers on Team plans and above) will be available until September 30th, 2019. Self service customer support will remain.

It’s a Great Time to Go Responsive! - Responsive design is the best way to create engaging online experiences on today’s web. With that in mind, we encourage you to take this as an opportunity to replace your old desktop-only websites and their mobile friendly counterparts with new responsive sites that will work seamlessly across desktop, tablet and mobile.

Alternate and Other Automatic Redirection Scripts

Overview

On this page, you will find many of the different code's that Duda Mobile provides for redirecting your site. By default Duda provides the JavaScript redirect code to embed directly into your HTML, but we also offer other server side options to assist in getting the redirect setup as well.

JavaScript Redirects

Standard redirect

This is the redirect you will use for 90% of your sites. If you are a direct DudaMobile user, install this redirect in your header:

<script type="text/javascript" src="http://static.dudamobile.com/DM_redirect.js"></script>
<script type="text/javascript">DM_redirect("ENTER_MOBILE_URL_HERE");</script>

Client Side Redirect using JavaScript

This method is the easiest to install. Simply paste the javascript code below into the head tag of your HTML page, and replace in the code the " http://m.example.com " with your mobile website domain (including http://).

<script src="http://static.dudamobile.com/DM_redirect.js" type="text/javascript"></script>
<script type="text/javascript">
  DM_redirect("http://m.example.com");
</script>

Note: some mobile devices like old blackberry models don't support JavaScript, if you would like to support those devices as well, you will need to use server-side redirection

Note: You will need to set up this redirect on all pages which you want to make mobile friendly.

HTTPS redirect

If you have a site that's using HTTPS or SSL, the standard redirect script won't work when loaded. Instead, use our HTTPS compatible redirect script.

Redirect script for direct users:

<script type="text/javascript" src="https://s3.amazonaws.com/static.dudamobile.com/DM_redirect.js"></script>
<script type="text/javascript">DM_redirect("ENTER_MOBILE_URL_HERE");</script>

Redirect script for WL users:

2018-02-13_16-20-22.png

***Note***: the following script is displayed as an image so that white labeled users will not see Duda references.

Cookie redirect

If your mobile site requires that users visit the desktop site on their mobile phones, you may encounter the issue with the redirect sending users in a loop due to the standard redirect script. To fix this, you can use cookies to tell the browser to not redirect after the user clicks a link to visit the desktop site (usually located in the footer of your website).

<script type="text/javascript" src="http://static.dudamobile.com/DM_redirect_cookie.js"></script>
<script type="text/javascript">DM_redirect("ENTER_MOBILE_URL_HERE");</script>

Note, that once a user visits the desktop website on their phones, the cookie redirect will stop redirecting users to the mobile site unless they clear their cookies and cache. Only use the cookie redirect if visiting the desktop site is a required.

Cookie and HTTPS redirect

A combination of the HTTPs and Cookie redirect. Remember to use the cookie redirect if required.

<script type="text/javascript" src="http://s3.amazonaws.com/DM_redirect_cookie.js"></script>
<script type="text/javascript">DM_redirect("ENTER_MOBILE_URL_HERE");</script>

True redirect script

You can use this redirect script to redirect users directly to a page on your mobile site. This is useful if you're experiencing certain issues with redirecting to the wrong homepage.

Note, that once a user visits the desktop website on their phones, the cookie redirect will stop redirecting users to the mobile site unless they clear their cookies and cache. Only use the cookie redirect if visiting the desktop site is a required.

<script src="http://static.dudamobile.com/DM_redirect.js" type="text/javascript"></script>

<script type="text/javascript"> DM_redirect("ENTER_MOBILE_URL_HERE", true);</script>

Redirect using server side snippet

The server-side method might be more complex to implement but will ensure that mobile devices who do not support javascript are supported as well. We offer code examples for PHP, ASP and JSP. Please replace the placeholder " http://m.example.com" in the code with your mobile website domain (including http://).

PHP

Paste the code below in the very beginning of your index.php file. Be sure to edit the m.example.com with your own mobile URL.

<?php
$mobileDomain = "http://m.example.com";
$no_redirect = @$_REQUEST['no_redirect'];
if($no_redirect != "true")
{
   $agent = @$_SERVER['HTTP_USER_AGENT'];
   @ini_set('default_socket_timeout',1);
   $handle = @fopen("http://mobile.dudamobile.com/api/public/detect?ua=" . urlencode($agent), "r");
   @stream_set_timeout($handle, 1);

   /* check if we should redirect*/
   $result = @fread ( $handle , 1 );

   @fclose($handle);
   if ($result == "y") {
       $currenturl = "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
       $mobileUrl = $mobileDomain ."?url=" .urlencode($currenturl);
       $mobileUrl=$mobileUrl."&dm_redirected=true";
       header("Location: ".$mobileUrl);
       exit;
   }
}
?>

ASP

Paste the code below in the very beginning of your index.asp file. Be sure to edit the m.example.com with your own mobile URL.

<%Dim no_redirect, detecturl, handle, output, currenturl, mobileUrl
no_redirect = Request.QueryString("no_redirect")
If no_redirect <> "true" Then
currenturl = ( "http://" & Request.ServerVariables("SERVER_NAME") & Request.ServerVariables("URL") ) & "?" & Request.ServerVariables("QUERY_STRING")
detecturl = "http://mobile.dudamobile.com/api/public/detect?ua=" & Server.UrlEncode(Request.ServerVariables("HTTP_USER_AGENT"))
set handle = CreateObject("MSXML2.ServerXMLHTTP")
handle.setTimeouts 5000,5000,5000,5000
handle.open "GET", detecturl, false
handle.send ""
output = handle.responseText
mobileUrl = "http://m.example.com" & "?url=" & Server.UrlEncode(currenturl) & "&dm_redirected=true"
If output = "y" Then
Response.Redirect(mobileUrl)
End If
End If
%>

JSP

Paste the code below in the very beginning of your index.jsp file. Be sure to edit the m.example.com with your own mobile URL.

<%@page import="java.net.URLEncoder"%>
<%@page import="java.net.URL"%>
<%@page import="java.net.HttpURLConnection"%>
<%
if(! "true".equals(request.getParameter("no_redirect")))
{
String currenturl = request.getRequestURL() + (request.getQueryString() != null ? "?" + request.getQueryString() : "");
try{
String ua = URLEncoder.encode(request.getHeader("user-agent"), "utf-8");
HttpURLConnection con = (HttpURLConnection)new URL("http://mobile.dudamobile.com/api/public/detect?ua=" + ua).openConnection();
con.setConnectTimeout(5000); //set timeout to 5 seconds
char c = (char)con.getInputStream().read();
con.disconnect();
if(c == 'y')
{
String mobileUrl = "http://m.example.com";
response.sendRedirect(mobileUrl + "?url=" + URLEncoder.encode(currenturl) + "&dm_redirected=true");
}
}
catch(Exception e){
e.printStackTrace();
}
}
%>

.htaccess (Advanced)

Install the following code at the bottom of your existing .htaccess file. Please be sure to backup your existing .htaccess file before you make changes. Installing the .htaccess code incorrectly can bring down your website easily.

Make sure you replace any reference of example.com with your own domain.

RewriteEngine on
######### Set cookie for users who return to desktop site
RewriteBase /
RewriteCond %{QUERY_STRING} no_redirect=true [NC]
RewriteRule ^(.*)$ - [co=dm_show_classic:true:.example.com:7200:/]
# check no 'dm_show_classic' cookie is set
RewriteCond %{HTTP_COOKIE} !dm_show_classic
# check if no_redirect was sent in the url
RewriteCond %{QUERY_STRING} !no_redirect=true [NC]
# check if the user agent matches supported mobile devices
RewriteCond %{HTTP_USER_AGENT} ((.*iPhone.*)|(.*iPod.*)|(.*BlackBerry.*)|(.*Android.*)|(.*webOS.*)|(.*Windows\ CE.*)|(.*IEMobile.*)|(.*Opera\ Mini.*)|(.*Opera\ Mobi.*)|(.*HTC.*)|(.*LG-.*)|(.*LGE.*)|(.*SAMSUNG.*)|(.*Samsung.*)|(.*Symbian.*)|(.*Nokia.*)|(.*PlayStation.*)|(.*PLAYSTATION.*)|(.*Nintendo\ DSi.*)|(.*TMO-US_LEO.*)|(.*SEC-SGH.*)|(.*BB10.*))
# check if the request isn't for a static file
RewriteCond %{REQUEST_FILENAME} !\.(jpg|gif|png|css|js|txt|ico|pdf|bmp|tif|mp3|wav|wma|asf|mp4|flv|mpg|avi|csv|doc|docx|xls|xlsx|ppt|pptx|zip|rar|tar|gz|dmg|iso)$ [NC]
#### If query string is not empty, then include ##############
RewriteCond %{QUERY_STRING} !^$
# extract the current page url including the query string
RewriteCond http://%{HTTP_HOST}%{REQUEST_URI}?%{QUERY_STRING} ^(.*)$
# redirect the request to mobile domain and pass the page url as a parameter
RewriteRule ^(.*)$ http://m.example.com?url=%1 [R=302,L]

×

Please Log in as a Pro

Priority Phone Support is available exclusively to Pros. Log in to your Pro account now to see our international support numbers.

Log In
Not a Pro? Purchase a Pro plan!