Question

I am working on a site and it has two templates, one for mobile devices and the main site view for pc users.

I already have a code in the index file of my site that will redirect users to root/m for mobile devices.

My problem is when working with links to specific pages/content, the user is redirected to the main page.

for example:

if a user visits www.projectnaija.com/index.php?page=addtopic&cid=11 from a mobile device

he/she is redirected to www.projectnaija.com/m

I want the redirect to www.projectnaija.com/m/index.php?page=addtopic&cid=11

any idea or useful tip?

Was it helpful?

Solution

use $_SERVER['QUERY_STRING'] to get the url query of the link before redirecting. for example

www.projectnaija.com/index.php?page=addtopic&cid=11

$url = $_SERVER['QUERY_STRING'];

$redirectTo = "http://www.projectnaija.com/m/index.php?{$url}";

i am not sure the best way but this will work, i think

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top