URL redirection or what we can call it  :

– URL forwarding

– Domain redirection

– Domain forwarding

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

url-redirection

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.

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.

URL-REDIRECTION

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”;
Response.AddHeader(“Location”,”http://www.newdomainl.com”);
}
</script>


4- ColdFusion Redirect

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


5- JSP (Java) Redirect

<%
response.setStatus(301);
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 123.123.123.123 with your IP )  :

RewriteEngine on
RewriteCond %{REQUEST_URI} !/yourpage.php$
RewriteCond %{REMOTE_ADDR} !^123.123.123.123
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/”
end


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

4 COMMENTS

  1. Hi superb website!
    I’ve no expertise in programming however I had been hoping to start my own blog in the near future. Anyway, your recommendations and tips for new blog owners helps.
    Thank you!

  2. It’s awesome to go to see this web page and reading the views of all colleagues on the topic of this paragraph, while I am also keen of getting familiarity.

  3. For me it doesn’t matter if you have a website with www or without it, the most important thing is to choose to keep only one.

  4. thanks for the post…but i have a question…my question is will it effect SEO? i have seen many website which have www in the domain and many of then are without www. whats the difference? will www get more visits?

Comments are closed.