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

Link to comment
https://forums.phpfreaks.com/topic/284528-two-in-query-string/
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
https://forums.phpfreaks.com/topic/284528-two-in-query-string/#findComment-1461277
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.