Tuesday, July 23, 2024

URL redirection the WHY and the HOW TO.

- Advertisement -spot_img
- Advertisement -Traffic Analysts Tool

URL redirection or what we can call it  :

– URL forwarding

– Domain redirection

– Domain forwarding

- Advertisement -Traffic Analysts Tool

are techniques on the WWW for making a web page available under many URLs.


I- why using  URL redirection ?

1- Similar domain names :

a) Users visiting a particular website may type the wrong spelling of it.  www.gp2b.com and www.gp2p.com. you can see that there is a spelling mistake by writing “p” and not “b”. Big companies often register these mis-spelled domains and redirect them to the correct domain name.

- Advertisement -Traffic Analysts Tool

b) Also redirecting domains for reserving Top Level Domains  -TLDs- . The addresses gp2b.biz and gp2b.net could both redirect to a single domain, such as gp2b.com .

2- Moving a website to a new domain :

a) A webmaster may want to move his pages to a new domain.

b) A web site might need to change its domain name.

c) Two web sites might merge.

3- Short aliases for long URLs :

Visitors can’t remember URLs like : www.gp2b.com/dir/dir2/dir3/index.php and this one reason when using forwarding might be helpful.

4- Manipulating search engines :

Search engines think that gp2b.com and www.gp2b.com are two different websites, and consider it as duplicate content. Redirect techniques can help solving this problem.

5- Manipulating visitors :

Sometimes URL forwarding is used for phishing attacks that confuse visitors about which website they are visiting.

6- Handling 404 error page :

When a visitor write a wrong URL in the adress bar it’s better to redirect him directly to second page, because no one like the white error pages to show out.


II- How to : URL redirection ?

1- PHP Redirect

Header( “HTTP/1.1 301 Moved Permanently” );
Header( “Location: http://www.newdomain.com” );

2- ASP Redirect

<%@ Language=VBScript %>
Response.Status=”301 Moved Permanently”
Response.AddHeader “Location”,”http://www.newdomain.com/”

3- ASP .NET Redirect

<script runat=”server”>
private void Page_Load(object sender, System.EventArgs e)
Response.Status = “301 Moved Permanently”;

4- ColdFusion Redirect

<.cfheader statuscode=”301″ statustext=”Moved permanently”>
<.cfheader name=”Location” value=”http://www.newdomain.com”>

5- JSP (Java) Redirect

response.setHeader( “Location”, “http://www.newdomain.com/” );
response.setHeader( “Connection”, “close” );

6- .htaccess Redirect

Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^newdomainn.com [nc]
rewriterule ^(.*)$ http://www.newdomain.com/$1 [r=301,nc]

For ERROR page use this code :

ErrorDocument 404 /index.php

For a maintenance page ( change with your IP )  :

RewriteEngine on
RewriteCond %{REQUEST_URI} !/yourpage.php$
RewriteCond %{REMOTE_ADDR} !^
RewriteRule $ /yourpage.php [R=302,L]

7- Ruby on Rails Redirect

def old_action
headers[“Status”] = “301 Moved Permanently”
redirect_to “http://www.newdomain.com/”

8- CGI PERL Redirect

$q = new CGI;
print $q-&amp;gt;redirect(&amp;quot;http://www.newdomain.com/&amp;quot;);

9- WordPress Plug-in

Redirection is a WordPress plugin to manage 301 redirections, keep track of 404 errors, and generally tidy up any loose ends your site may have. This is particularly useful if you are migrating pages from an old website, or are changing the directory of your WordPress installation.

You can download it directly from the extend page at wordpress.org

- Advertisement -
Latest news
- Advertisement -

Liquid Web Storm VPS
Related articles
- Advertisement - Traffic Analysts Tool