PHP Redirect To Page: If you are one of those PHP enthusiasts have got a set of pages up and running over the internet. And all of sudden you get this feeling that a particular page’s name has become out of vogue now.
A very few and that too a generation has gone by, know that this page of yours is to be accessed by this name. In a crux, you need to rename a file tree. But the problems start cropping up once you are done with the process. After changing the location of the pages, search engines may send users to a faulty address.
PHP Redirect To Page
And to make it even worse, if luck is not on your side, the page’s SEO may also be completely reset. But you need not worry as we have come up with a straight and simple solution which makes sure that Google is able to give the correct address of your pages and SEO is also maintained.
- Simple Redirection
We would get started with simple redirection headers in PHP which are very much helpful in conditional loops. You need to simply use following set of codes:
<?php header('Location: mypage.php'); ?>
As evident, out here, mypage.php will be the address of the page which you would like to redirect the visitors. If you want, you can also have this address as an absolute on and may also include the parameters in this format:
Check: Best Torrent Sites.
Another solution is to go for the absolute path and the case becomes an ideal one if you are dealing with the relative or absolute path. Use the following format to PHP redirect:
<?php header('Location: /directory/mypage.php'); ?>
And if you have got your target page on another server, you include the full URL:
<?php header('Location: http://www.thereportertimes.com/technology/'); ?>
- // $url should be an absolute url
header(‘Location: ‘ . $url);
Also: Best Torrent Clients.
Another way to get the task done is to send HTTP headers. But while doing so, one must keep it in mind that according to HTTP protocol, HTTP headers must be sent before any type of content. And that clearly enunciates that no characters should ever be sent before the header — not even an empty space!
PHP redirect: Temporary/Permanent Redirections
All the redirection we have used till now are supposed to be temporary ones. And what it means is that search engines, such as Google, will not take the redirection into account when indexing.
So, you might now wanna tell these guys that this shift is not a temporary one and you have moved them for good. It helps in maintaining the SEO of a site. To do so, use the following code:
<? header('Status: 301 Moved Permanently', false, 301); header('Location: new_address'); ?>
Check: Xbox Project Scorpio.
For example, this page has the following code:
<? header('Status: 301 Moved Permanently', false, 301); header('Location: /pc/imprimante.php3'); exit(); ?>
And from now onwards, whenever you click on the old link, you will be directed to the new location of your page. And even if type in the older address by mistake, the Google would be smart enough to take you to present location only.
Check: What is Runtime Broker?
Interpretation of PHP Code
The PHP code located after the header() will be interpreted by the server, even if the visitor moves to the address specified in the redirection. And this means that you will have to follow the header() function of the exit() function so as to decrease the load on the server. Here is what you can do:
<? header('Status: 301 Moved Permanently', false, 301); header('Location: address'); exit(); ?>
Hope you got to know how to PHP redirect to a new web page. Any queries?
Related: Best Free VPN.
When to use PHP redirect to Page: What are the benefits
If a page is no more relevant and needs to be removed, then it’s a good idea to redirect to a more useable and active & updated page on your site. Without the redirection, the visitors will remain dead, broken on the irrelevant page.
Benefits are as follows:
- Users are redirected quickly and seamlessly.
- When the Back button is clicked, visitors are taken to the last viewed page, not the redirect page.
- The redirect works on all web browsers.
Stay tuned to TheReporterTimes for more How-To information.
Alll tһe responsibility іs ߋn mе.