HTML Vs. PHP Redirects

HTML Vs. PHP Redirects thumbnail
Both HTML and PHP redirects require a Web page to be maintained at the old address.

The Hypertext Markup Language is a data formatting language that is used to define the layout of all Web pages. HTML is not a programming language. HTML pages are static and wait on a server in their complete state until requested. PHP is a programming language that generates HTML pages. The page does not exist until it is requested. Both systems contain different methods for redirecting requests to different addresses.

  1. Redirection

    • Sometimes Web pages change their addresses. When this happens all old links pointing to the old address will break. Browsers requesting the page at the old address will be told that the page does not exist. Website administrators can avoid this failure by putting a redirect in place. The redirect tells the Web server to inform browsers of the page's new address.

    HTTP Redirection Codes

    • The standard method for redirection is outlined in the Hypertext Transfer Protocol. HTTP contains a list of status codes. Two of these are for permanent and temporary redirect. The permanent redirection code is 301 and the temporary redirection code is 302. Administrators can delete the file from its old address and set up redirection in the configuration of the website. This informs the Web server to notify browsers of the new address by using one of the redirect codes. All browsers know to reapply at the new address for the required page when they receive a redirect code from the Web server in response to their request for the page at the old address.

    HTML Method

    • HTML contains an instruction to the Web browser to reload the page after a delay. The command appears in the “head” section of the Web page. It requires two parameters, the delay in seconds and the address from which to reload the page. This command gives Web developers an opportunity to create redirects from within Web pages. If the command contains a different address to the current one the browser will reload the page from a file at a different address. The command is called a “meta refresh.”

    PHP Method

    • PHP contains a function called “header.” This is a simple instruction to the Web server to send a redirect code in the response for the page. The default code for the command is the 302 temporary redirect code. The command can also instruct the server to send the 301 code.

    Comparison

    • Both the HTML method and PHP method for redirection are very simple. The HTTP codes used by the PHP method are generally preferred by search engines to the meta refresh method of HTML. Meta refresh redirects offer more scope for disruptive activities, such as hijacking the rankings of other pages and falsely inflating the hit count of a page. Both the HTML and PHP codes require the old page to continue in existence, which is a major detraction. The standard method of setting up HTTP redirect codes in the configuration of the site enable the old pages to be removed.

Related Searches:

References

  • Photo Credit John Foxx/Stockbyte/Getty Images

Comments

Related Ads

Featured