PHP Redirection Redirecting URL Tutorial, PHP Redirecting URL
Posted on: April 14, 2006 at 12:00 AM
If you are moving from one hosting company to another, you should know how to keep your existing visitors and redirect them to a new location.

In this tutorial I would like to describe three possible ways of redirecting a visitor to any other URL. Also you can read here PHP, HTML and JavaScript redirection source examples.

The first method stands on HTTP protocol advantages. Any HTTP answer sent to browser from the server has two parts: the header and the body.

Header part contains some special fields describing transferred data. This helps the broswer to understand and to show received data in proper way. For example any web programmer should know about the Content-Type header field, which is used to specify the data type.
In this tutorial we need another header field:

Location: URL
URL here is the address for browser to where it should be redirected. When the browser receives the HTTP header with Location field set it ignores all other data and jumps to another location specified in URL.

Perl source code.
It is easy to write a redirection in Perl:

print "Location: http://roseindia.net\n\n";

But you must remember to write this string before any other output. Actually it is the only needed line of output in your redirection script. Note that \n\n symbols in the end of the string. This is a separator between the HTTP header and HTTP body parts and it is necessary to be included.

PHP source code.
In PHP there is a special function called header(). You can specify all HTTP header fields in this function.
Just for redirecting you can use:

header("Location: http://roseindia.net");

Again, remember to write this line before any output operation. Otherwise your header will be generated by the web server and this line would be interpreted like just text.

The second redirection method stands on HTML language. There is a META tag, to be used for redirection needs.
Syntax:

<META http-equiv="refresh" content="0; url=http://roseindia.net">

You can even write the number of seconds into content parameter to allow browser wait before redirection. This tag should be used only in the HEAD part of the HTML page.
Example of the HTML page with redirection:

<HTML> <HEAD> <META http-equiv="refresh" content="0; url=http://roseindia.net"> </HEAD> <BODY> <H1>Redirect page</H1> </BODY> </HTML>

The third method is about using JavaScript. I suggest to use this seldom, because user is allways able to turn off the JavaScript on his browser. This is a JavaScript command for a browser window to move to another location.

window.location=http://roseindia.net;

Example:
Source code:

<form><input onClick=window.location="http://roseindia.net" type=button value=Redirect></form> More Tutorials on roseindia.net for the topic PHP Redirection Redirecting URL Tutorial, PHP Redirecting URL.
PHP Redirection Redirecting URL Tutorial, PHP Redirecting URL
In this tutorial I would like to describe three possible ways of redirecting a visitor to any other URL. Also you can read here PHP, HTML and JavaScript... specified in URL. Perl source code. It is easy to write a redirection in Perl
 
fetch url in php - PHP
fetch url in php  How to Fetch URL in PHP
 
Servlet Redirecting - JSP-Servlet
= req.getParameter("pwd"); //Redirect call to another url..."); String pwd = req.getParameter("pwd"); //Redirect call to another url
 
PHP add parameter to url - PHP
PHP add parameter to url  need an example of parse_url in PHP. Thanks in advance
 
php parse string for url
php parse string for url  Do i need a regex to parse a URL-type string in PHP
 
PHP Displaying URL Content
PHP Displaying URL Content  In my PHP application form, on submitting the form details it always displaying url content. Can anyone tell me what is the reason and how to restrict it from displaying
 
Complete php tutorial
Complete php tutorial  Hi, I am trying to find the url to learn complete PHP in easily. Can some one provide me url for complete php tutorials... Learn PHP at PHP - Hypertext Preprocessor tutorial page. Thanks
 
php download file from url
php download file from url  how to download multiple files in PHP using the URL's
 
Best PHP tutorial for beginners
Best PHP tutorial for beginners  Hi Friends, I want to learn PHP... PHP from beginning. PHP Tutorial index page. You find good tutorials... MySQL Tutorial index page. Above tutorials will help you in learning PHP from
 
Redirecting the console output into a file in Java
Redirecting the console output into a file in Java  Hi, i coded a program that read specific lines from a text file. It's working well. Now i want to redirect the output of the console to a text file. i used your tutorial
 
how do i grab the url in php?
how do i grab the url in php?  I want to grab the 'entire' url, including any special characters like & and #, from a site. I then want... # = %23 I tried URL encoding but it only grabs the part until the #, which
 
Why PHP ?
Why PHP? Reasons to use PHP are given below: 1.    PHP is open source, free to download and use : PHP is free and you can download... not restrict other software etc. 2.     PHP is cross
 
PHP Tutorial
PHP Tutorial  Hi, I am new in PHP programming. Can anyone provide me good urls to learn PHP? Thanks   Hi, Start learning PHP at PHP Tutorial section. Thanks
 
PHP
PHP PHP stands for Hypertext Preprocessor; PHP is server-side scripting language for development of web applications. PHP powerful and robust programming..., Roadsend PHP, Phalanger, Quercus, Project Zero and HipHop framework. PHP
 
PHP Tutorial
on roseindia.net PHP Tutorial (adsbygoogle = window.adsbygoogle || []).push...PHP Tutorial  Hi, I am looking for PHP tutorials on roseindia.net. Provide me the urls of PHP tutorials? Thanks (adsbygoogle
 
Get Variable in PHP Video tutorial
In this tutorial you will learn to use GET variable in PHP with the help... GET variable in PHP as the tutorial has been described with simple example... with the tutorial you will finally know about how to use GET variable in PHP easily and can
 
Redirecting Page

 
Preventing URL rewriting
. Mow the problem is after the user has logged in he/she copies the url. after logged out if he/she rewrites the url then it is redirecting to the same page has...Preventing URL rewriting  Hi. I have a login in page. After the user
 
Preventing URL rewriting
. Mow the problem is after the user has logged in he/she copies the url. after logged out if he/she rewrites the url then it is redirecting to the same page has...Preventing URL rewriting  Hi. I have a login in page. After the user
 
PHP Variables from URL
PHP Variables from URL Are you facing problem passing PHP variable from URL... one thing if you are passing unnecessary information in the URL is fine but if you are passing confidential information like password or username in the URL
 
Redirecting and forwarding to views
In this section, you will learn about redirecting and forwarding views through prefixes
 
PHP Installation, Installing PHP on windows
at http://roseindia.net/tutorial/php/phpbasics/Downloading-Installing-Wamp.html....://roseindia.net/tutorial/php/phpbasics/Running-Testing-Wamp.html In this section you...PHP Installation Learn how to install PHP on your windows and then test
 
PHP - Ajax
PHP  How can ajax is used in php,plz expalin with example.  ... showCurrentTime(){ var rnd = Math.random(); var url="time.php?id="+rnd; postRequest(url
 
PHP Form, PHP guest form
;); The whole PHP code from the first part of the tutorial will look like...PHP email form HTML form It's not a good idea to leave your private e... of this tutorial I'll tell you in details how to create a mailbox
 
Sitemap PHP Tutorial
Questions | Site Map | Business Software Services India PHP Tutorial... Tutorial Section Why PHP Is So Useful | Evolution of PHP for Scripting Needs... Tutorial Section - IIADS_TO_REPLACE_2 PHP Beginners Guide | About PHP | PHP
 
Servlet Redirecting - JSP-Servlet

 
ppt php tutorial
ppt php tutorial  How can i work with ppt files in PHP
 
PHP Ajax tutorial
PHP Ajax tutorial  Hi, I am learning Ajax with PHP. Provide me few examples of Ajax with PHP. Thanks   Hi, Here are few tutorials: PHP Ajax and Database Getting Started with Ajax Thanks
 
PHP jQuery Example
PHP jQuery Example jQuery:  jQuery is a JavaScript library which... Extensibilty Utilities ....etc. In this tutorial you will come to know about... this file into the directory where you will develop the php files. .style1
 
HTTP Authentication With PHP
HTTP Authentication with PHP: The HTTP Authentication is available when...) and for doing so we pop up a user-validation window. After filling the form the url which contains the PHP script is again called with the predefined variables
 
Array length in PHP - PHP
Array length in PHP  a function to get the array length in PHP.  Hi Friend, Please visit the following link: http://www.roseindia.net/tutorial/php/phparray/php-array-length-for.html Thanks
 
Replace String in PHP - PHP
Replace String in PHP  What is the fastest way of replacing string in PHP Code?  Hi Friend, Please visit the following link: http://www.roseindia.net/tutorial/php/phpbasics/PHP-Array-Replace.html Thanks
 
PHP Ajax and Database
PHP Ajax and Database:       In this following tutorial we will study how to connect PHP, JavaScript... not support HTTP Request"); return; } var url="phpAjaxDB.php"; url
 
PHP 5.4.23 Features
PHP is the most popular open source, rich featured and high level web... servers. The PHP (Hypertext Preprocessor) scripting language is widely used by developers for creating complex and high level web applications. PHP has rich
 
PHP MYSQL Interview Questions
the domain name of website from the full URL path? In my PHP application, i have...PHP MYSQL Interview Questions  What kind of questions can be asked in an PHP, MYSQL interview? Can anyone post the PHP interviews questions with well
 
PHP and jQuery Tutorial
PHP and jQuery Tutorial  Hi, I have to develop web application using PHP programming language. In my program I have to add Ajax support with the help of jQuery. Let's know which Ajax framework is very good? Shall I learn
 
Static Method in PHP - PHP
Static Method in PHP  So far I can easily use the normal functions as variable in PHP? but how can use static method?  Hi Friend, Please visit the following link: http://www.roseindia.net/tutorial/php/phpoop/php
 
Multidimensional Array in PHP - PHP
/tutorial/php/phparray/arraymultidimension.html Thanks... in PHP completely goes over my head. Can any one present a better explanation on it with an example? Also the structure of Multidimensional Array in PHP
 
php video tutorial for beginners with examples
php video tutorial for beginners with examples  php video tutorial for beginners with examples   PHP: Hypertext Preprocessor PHP is an open source server side scripting language. One can use PHP to create dynamic web
 
php
php   what is php   PHP Tutorials
 
php
php  what is php
 
PHP AJAX Introduction
PHP-AJAX-Introduction In this current tutorial we will study how to integrate a simple PHP file with AJAX, how to put some AJAX affect in a PHP file... not support XMLHTTP!"); return; }ADS_TO_REPLACE_33 var url="php
 
PHP with AJAX
://www.roseindia.net/tutorial/php/phpdatabase/ http://www.roseindia.net/php/PHP-Ajax.shtml...PHP with AJAX  I want to update records of table in database using AJAX PHP MySQL. How can this be done using AJAX.   Please visit
 
Recursive regex PHP - PHP
Recursive regex PHP  any one? that can send me the code of regular expression that checks other regular expression for its correctness.   Hi, Please check at http://www.roseindia.net/tutorial/php/phpbasics/PHP
 
PHP Tutorial
programmer. Our beginners PHP tutorial is full of examples that will help...The Roseindia Technologies has offered this tutorial for the beginners who want to gain the comprehensive knowledge in the PHP fundamentals. This beginner
 
PHP Basics Tutorial Index
PHP Basic Tutorial: Learn the Basics of PHP scripting through our PHP Basic Tutorial series. The PHP Basic Tutorial is design for new programmers who want... Basics easily. The PHP Basics tutorial is supported with the example code. Let's
 
php
php using javasript  how to set timer in php using javasript
 
Redirecting the output of an expression to a variable - JSP-Servlet
Redirecting the output of an expression to a variable  I want to redirect the output of to a variable defined in variable.jsp. What is the syntax for this?   Hi Friend, Use the following code in your 'variable.jsp
 
php mysql web application tutorial
php mysql web application tutorial  How to create a simple php mysql web application? Please post an example or tutorial
 
verfication of user login and then redirecting it to user defined page
verfication of user login and then redirecting it to user defined page  hi, i have a login page that..calls the servlet..and i have used redirect...,the html page calls teh servlet..but..the servlet.is not redirecting to a user defined
 
Ads

Related Tags for PHP Redirection Redirecting URL Tutorial, PHP Redirecting URL:


Ads

 
Advertisement null

Ads