It seems like you you're looking for some kind of redirection here.
I'm not sure if you're thinking of using entirely javascript here, as you've shown a PHP file extension.
Javascript
For a Javascript-only solution, you might try something like this:
//Parameter function thanks to https://stackoverflow.com/a/901144/917035
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
//Build the new location string.
var page = getParameterByName("page");
var id = getParameterByName("id");
var locationString = 'http://website.com/src/popup.page?page=' + page + '&id=' + id;
//Redirect
window.location = locationString;
Alternatively you could achieve the same thing with PHP:
PHP
<?php
$page = $_GET['something'];
$id = $_GET['id'];
$locationString = 'website.com/src/popup.page?page=' . $page . '&id=' . $id;
header('Location: ' . $locationString);
?>
Which would take the parameters in your URL query (page
and id
) and then pass them into the header
request to redirect the user away.
If you're looking for a long-term solution for all pages, there are options available in the ways of editing your .htaccess
files, similar to how this answer uses a RewriteRule
to preserve the parameters.