gasguirre gasguirre - 1 year ago 54
PHP Question

Make dynamic redirection php based on parameters sent

let´s say that I have a url that is parametrized to redirect to other url.


and I have the following in redirect.php

function getURLParameter(name) {
return decodeURI(
(RegExp(name + '=' + '(.+?)(&|$)').exec( || [, null])[1] || ''

var param1 = getURLParameter('param1');
var param2 = getURLParameter('param2');
var param3 = getURLParameter('param3');
var param4 = getURLParameter('param4');

var url = ''+param1+'?param2='+param2+'&param3='+param3+'&param4='+param4';

header('Location: url');


now, the idea is that the parameters that comes from the first url calling redirect.php works to fill what I want that recirect.php do.

to then redirect to a dynamic url based on the parameters received.

is this possible?

maybe there is something wrong in my code, please help me.

Answer Source

Do you need to do the redirect in PHP?

If not, you could do window.location = url; or window.location.replace(url);