How to Pass URL Parameters and Keep SEO Value When Redirect A Page to Another URL?

Published on : November 18, 2016

Author:

Category: SEO and PPC


Sometimes while working you may have a situation when you want to redirect a page with its parameters to a new page and keep it’s SEO juice.

For Example https://www.example.com/page-one.php?phone=9999999999&[email protected]

You want to redirect this page along with its phone and email parameters to https://www.example.com/page-two.php

The following images will give you a clear sense

301redirect in php with query parameter

This landing page one contains 2 query parameters ad_tracking and phone, now when we redirect the page to landing page two we pass its parameters as the screenshot below

 

redirect URL and parameters

Take into account the following points while making that page redirect:

  1. Get clear sense on your pages SEO value
  2.  If this page is currently being used on AdWords, Bing or any other campaign make sure you comply their page redirect rules
  3. If this page is currently being used in any A/B Test make sure it will work as intended after page redirection

 

We will use a PHP script to redirect the page, the most common redirect types are

  1. 301, “Moved Permanently”
  2. 302, “Found” or “Moved Temporarily”

 

You can google redirect types to know more details

 

Here is the simple code you should use on top of your page to get it redirected and pass its parameters

 <?php

$redirect_page = "https://www.example.com/page-two.php";

if($_SERVER['QUERY_STRING']){

$query_sign = "?";

}else{

$query_sign = "";

}

header("Location: $redirect_page.$query_sign".$_SERVER['QUERY_STRING'], true, 301);

exit;

?>

Note : one thing on the header() function you must use HTTP status code, here we used 301. If you don’t use any status code by default it will be redirected as 302 temporary redirects which is not really ideal for SEO.


Leave a Reply

Your email address will not be published. Required fields are marked *