Adding a mobile site redirect

Dr. GBooky is here to help you with your guestbook problems ...
Post Reply
Annie
Posts: 20
Joined: Sat May 15, 2010 5:08 pm

Adding a mobile site redirect

Post by Annie »

Script URL:
Version of script: 1.7
Hosting company:
URL of phpinfo.php:
URL of session_test.php:
What terms did you try when SEARCHING for a solution:

Write your message below:

I am wondering whether there's a way to add the following code to just the View Guestbook page and not the Sign Guestbook page or any other pages of the guestbook.

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

The script is a redirect to a mobile version of the website. The problem is that I'm having to get site visitors to use the desktop version of the guestbook to add comments as the mobile version doesn't work (doesn't show the CAPTCHA). However, I'd like visitors to be able to read the comments on the mobile version.

If I place the code in the overall_header file, as per the instructions, then an error occurs on the Sign Guestbook page because this particular page is not mobilized at DudaMobile. Obviously, things are getting stuck in a loop. Conversely, if I remove the redirect script, then people arriving on the 'View Guestbook' page from a search engine aren't seeing the mobile site until they click on another page link.

I'm not technical with php so I wonder if anyone could walk me through what I'd need to do to add the code to just the View Guestbook page.
Henrie
Posts: 1095
Joined: Sun Aug 14, 2005 8:57 pm

Re: Adding a mobile site redirect

Post by Henrie »

Hello Annie,

I did not test it, but I think the following should work.
Put the following code in the overall_header.php file just before the </head> tag.

Code: Select all

<?php 
$a=htmlspecialchars($_REQUEST['a']);
if (empty($a)) 
{ 
	echo '<script src="http://static.dudamobile.com/DM_redirect.js" type="text/javascript"></script>
	<script type="text/javascript">DM_redirect("http://m.example-domain.com");</script>';
}
?>
Greetings,
Henrie
I do not monitor the Gbook forums regularly anymore since I do not use the Gbook script myself anymore for a long time. But it helped me a lot in learning to understand php.
Annie
Posts: 20
Joined: Sat May 15, 2010 5:08 pm

Re: Adding a mobile site redirect

Post by Annie »

Thanks Henrie, that worked a treat. Only thing it didn't do was go back to the mobile version of the page after submitting a comment but that's not the end of the world.
balmerhevi
Posts: 1
Joined: Thu Nov 10, 2016 7:03 am

Re: Adding a mobile site redirect

Post by balmerhevi »

The following Javascript code will help you to redirect to your mobile version.

<script type="text/javascript">
if (screen.width <= 699) {
document.location = "mobile/mobilepage.html";
}
</script>

Hevi
Post Reply