Methods to redirect URLs (HTML, PHP and Javascript)

romeo

Newbie
Messages
27
Likes
0
Points
1
In this tip , I show you several methods to redirect URLs. That is, that when you enter a web page automatically sent to another.

Method 1. HTML

The first method is to use the element GOAL . Let syntax use for our purpose:
Code:
<Meta  http-equiv = "action"  content = "seconds" ; url = "url destination"  />

Suppose you changed your server or you have moved a page to another directory. Show a message about it and are forwarding our user to the new page location. In this example, the action will "refresh" the time it takes to refresh the page shall be five (5) seconds:
Code:
<Html> 
<head> 
<meta  http-equiv ="Refresh"  content ="5; url=http://www.blackhatboard.com" > 
</ head>

<Body> 
<p> We have moved! You will be automatically redirected in five seconds. Otherwise, you can access by clicking <a  href = "http://www.blackhatboard.com"> here </a> </ p> 
</ body> 
</ html>

Method 2. PHP

The following example will redirect the user without notice:
Code:
<? php
header ( "Location: http://www.blackhatboard.com" ); 
>?

3. Method JavaScript

We can do with JavaScript , the methods previously seen. In the case of a redirect on hold, we must use a "timer". Here's an example:
Code:
<html> 
<head> 
<script  type = "text/javascript" > 
function redireccionar (){ 
  window . locationf = "http://www.blackhatboard.com" ; 
}  
setTimeout ( "redireccionar()" ,  5000 );  //tiempo in milliseconds 
</ script> 
</ head> 
<body> 
<p> Please wait will be redirected in five seconds. </ p> 
</ body> 
</ html>

Making directly, without waiting:
Code:
<Body> 
<script  type = "text / javascript" > 
window . location = "http://www.blackhatboard.com" ; 
</ script> 
</ body>

:)
 

Members online

No members online now.