Sunday, October 20, 2019
PHP Web Page Redirect Script
PHP Web Page Redirect Script A PHP forwarding script is useful if you want to redirect one page to another so that your visitors can reach a different page than the one they land on. Fortunately, its really easy to forward with PHP. With this method,à you seamlessly transfer visitors from the web page that no longer exists to the new page without requiring them to click a link to continue. How to Redirect With PHP On the page that you want to redirect elsewhere, change the PHP code to read like this:à ?php header( Location: yoursite.com/new_page.html ) ; ? Theà header()à function sends a raw HTTP header. It must be called before any output is sent, either by normal HTML tags, by PHP,à or by blank lines. Replace the URL in this sample codeà with the URL of the page where you want to redirect visitors. Any page is supported, so you can transferà visitors to a different webpage on your own site or to a different website entirely. Because this includes theà header()à function, be sureà that you do not have any text sent to the browser before this code, or it will not work. Your safest bet is to remove all the content from the page except for the redirect code. When to Use a PHP Redirect Script If you remove one of your web pages, its a good idea to set up a redirect so that anyone who bookmarked that page is transferred automatically to an active, updated page on your website. Without the PHP forward, visitors would remain on the dead, broken, or inactive page. The benefits of this PHP script 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. Tips for Setting up a Redirect Removeà all code but this redirect script.Mention on the new page that users should update their links and bookmarks.Use this code to create a drop-down menu that redirects users.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.