URL redirection the WHY and the HOW TO.

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


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-&gt;redirect(&quot;http://www.newdomain.com/&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

You May Also Like

What Should You Look For In A Web Designer?

Choosing the right professional to design your website is extremely important. The quality of your website can make a huge difference to your presence on the internet – and consequently on your success. Here are some traits and services held and offered by good web designers. Sensible Pricing Some unscrupulous designers take advantage of people […]

Ways to Optimize your blog for Mobile Searching

Would you believe this? The number of people accessing the web through their mobile phones has doubled from last year and at present; 22 million people search the net for various reasons everyday. WOW! That is an awesome number and it promises to grow exponentially with each passing day with most of the mobiles today […]

Design Pickle: How to Transform Creative Operations From Chaos to Consistency

Your creative operations don’t need more designers. They need better infrastructure. That’s what Design Pickle solves, by bringing order to the chaos of managing multiple designers, conflicting file formats, brand inconsistency, and unpredictable costs. Your inbox is drowning in design requests. Three different designers submitting in three different formats. Your CFO asking why costs keep […]