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.


2 replies on “How to Pass URL Parameters and Keep SEO Value When Redirect A Page to Another URL?”

Oh my goodness! Amazing article dude! Thank you so much, However I am experiencing troubles with your RSS.
I don’t understand the reason why I cannot join it.
Is there anybody getting similar RSS issues?
Anyone that knows the solution can you kindly respond?

Thanks!!

Thank you so much for the kind feedback! I’m really glad you found the article helpful.

Regarding the RSS issue, the feed should be working correctly. You can try accessing the RSS feed directly here:
https://www.cybernetikz.com/feed/

If you’re unable to subscribe, it might be due to your RSS reader, browser extensions, or caching issues. Sometimes clearing the browser cache or trying a different RSS reader can resolve the problem.

Also, if you’re using a specific RSS reader or app, please let me know which one you’re using so I can check and help troubleshoot the issue. Your feedback helps us improve the site and make our WordPress tutorials more useful for everyone.

Thanks again for visiting and supporting the article!

Leave a Reply

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