PHP Redirect Vs. Domain Redirect

PHP Redirect Vs. Domain Redirect thumbnail
Redirects alter the addresses of web sites.

Redirecting is when a web server or a web page forwards the visitor to a page other than the one the user expected to visit. This may be because the web site has been reorganized or renamed and the required page is still available, but at a different address. Another reason is that several web addresses show the same content, or a long web address has been substituted for a shorter, more accessible address.



Many different ways exist to implement a redirect. The redirect may be commanded from the web site's control panel, as in a domain redirect, or it may be a programmed event from within the target file, as in a PHP redirect.

  1. PHP

    • PHP is a programming system that generates HTML code. HTML is the Hypertext Markup Language, and all web pages are written in HTML, but it is not a programming language; it only formats text for display. PHP generates HTML pages. Usually, a PHP program contains a page template -- sections of that template are filled in when the program is called, and that produces a complete web page. These are called dynamic web pages and with them, you can program a redirect to move visitors immediately from the current address to another address, to move content from another address to the current address, or to lead the user through a sequence of events and then implement a redirect in reaction to the user's responses.

    Domain Redirect

    • A domain is a web site name, like "www.something.com." A domain redirect is also called domain forwarding. In this category, and entire website is moved to a different location, not individual pages. The main technique for redirecting a web address is to place a rewrite instruction in the home directory of the old site, which substitute the characters for the old address with the new address. It is a simple text replacement technique. So if the text replacement is from "example.com" to newsite.net and request for any page on example.com is automatically changed to newsite.com. The rewrite instruction is written either in the configuration file of the site or in a special file called ".htaccess" which is resident in the site's home directory.

    HTTP Codes

    • The transfer of web pages between web servers and web browsers follows the Hypertext Transfer Protocol, or HTTP. HTTP has a number of standard status and instruction codes and web browsers know how to act when sent one. The 301 code is a redirect code. It tells the browser to not use that address, but substitute a new address instead. The 302 code tells the browser to go to the new address, but to use the old address again next time, because the page has only been moved temporarily. HTTP codes can be set for an entire domain, creating a domain redirect, or they can be produced by a PHP program.

    Basic Comparison

    • By its nature, a domain redirect is not made for subtleties. It shifts the address of an entire website from one domain to another. The programming functionality of PHP allows redirection to occur under certain conditions, and alternative redirects can be invoked according to some piece of data, or action from the user.

Related Searches:

References

  • Photo Credit John Foxx/Stockbyte/Getty Images

Comments

Related Ads

Featured