Jump to content

Two ? in query string


Stefan83

Recommended Posts

Hi

 

I'm redirecting wireless devices to a page that delivers different content based on the device OS. I'm using WURFL to do this.

 

The following code gets the landing page URI and redirects mobile devices to domain.com/mobile/?from=previousPageURI

elseif ($client->getDeviceCapability('is_wireless_device'))
{
$source = '';
if(isset($_SERVER['REQUEST_URI']) && $_SERVER['REQUEST_URI'] != '/');
   $source = urldecode($_SERVER['REQUEST_URI']);
header("Location:/mobile/?from=$source");

}

The issue I'm having is if the referral URL already has a query string attached, I get two '?' in the URL. So domain.com/?example=1 redirects to domain.com/mobile?from=?example=1

 

How do I resolve this?

 

Thanks

Edited by Stefan83
Link to comment
Share on other sites

Thanks guys, that's great.

 

Now, on the mobile landing page, I'd like include different content based on referral URL. So if the URL is domain.com/mobile/?from=%2F%3Fnov13%3Dtest1 I'd like to load nov13.php

 

But I'd also like to load nov13.php file when the value is test2, test3 etc. How do I rewrite the array below for this wildcard variable?

 

<?php

$mapping = array(

'%2F%3Fnov13%3Dtest1' => 'inc/mobile/nov13.php'

'%2F%3Fnov13%3Dtest2' => 'inc/mobile/nov13.php'

'%2F%3Fnov13%3Dtest3' => 'inc/mobile/nov13.php'

'%2F%3Fnov13%3Dtest4' => 'inc/mobile/nov13.php'

 

);

 

if(array_key_exists($_GET['from'], $mapping))

include $mapping[$_GET['from']];

else

include 'inc/mobile/default.php';

?>

 

 

Thanks

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.