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
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
Take into account the following points while making that page redirect:
We will use a PHP script to redirect the page, the most common redirect types are
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.