
HOW TO: Create 301 URL Redirection
- Updated On 05/04/2017
- Author : Pradeep Kumar
- Topic : HTACCESS
- Short URL : http://hbb.me/2ozdXcX
CONNECT WITH HBB ON SOCIAL MEDIA
URL redirection is also called URL forwarding, URL shortener, domain redirection and domain forwarding.
Why to redirect a website?
For Similar Domain Names :
A user accessing a particular domain name may type the wrong spelling of it. For example, consider www.hellboundbloggers.com and www.helboundbloggers.com. Here one ‘l’ is missing in the second domain name. Organizations often register these mis-spelled and redirect them to the correct domain name. Another example is redirecting domains for reserving TLDs (Top Level Domains). The addresses hellboundbloggers.com and hellboundbloggers.net could both redirect to a single domain, such as hellboundbloggers.org.
MUST READ : Introduction To HTACCESS For Newbies
Moving a website to a new domain :
A webpage or website can be redirected for many reasons like the website might need to change its domain name or the author of that website might move his or her pages to a new domain.
HTTP Status codes for redirect :
- 300 Multiple ChoicesΒ (like offering different languages)
- 301 Moved Permanently
- 302 Found (like temporary redirect)
- 303 See Other (For results of CGI-Scripts)
- 307 Temporary Redirect
Common Methods for Redirecting A Website [URL Redirection]
Open Notepad or any other editor and copy the required code and save it. Then upload that file to your directory. I made use of the PHP redirect for redirecting My Mobile Site to Google Reader. I made mobile version of my blog through Google Reader.
ColdFusion Redirect
<.cfheader statuscode="301" statustext="Moved permanently">
<.cfheader name="Location" value="http://www.new-url.com">
PHP Redirect
<?
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://www.new-url.com" );
?>
ASP Redirect
<%@ Language=VBScript %>
<%
Response.Status="301 Moved Permanently"
Response.AddHeader "Location","http://www.new-url.com/"
%>
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.new-url.com");
}
</script>
JSP (Java) Redirect
<%
response.setStatus(301);
response.setHeader( "Location", "http://www.new-url.com/" );
response.setHeader( "Connection", "close" );
%>
.htaccess Redirect
Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^domain.com [nc]
rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]
CGI PERL Redirect
$q = new CGI;
print $q-&gt;redirect(&quot;http://www.new-url.com/&quot;);
Ruby on Rails Redirect
def old_action
headers["Status"] = "301 Moved Permanently"
redirect_to "http://www.new-url.com/"
end
HTML Redirect
Place the following HTML code between the <HEAD> and </HEAD> tags of your HTML code.
<meta HTTP-EQUIV="REFRESH" content="0; url=http://www.yoursite.com/">
Want to discuss your queries and interact with experts? You can connect with HellBound Bloggers (HBB) Facebook group for free!
Join HellBound Bloggers (HBB) and get Instant Updates. We'll also notify you with Great Deals, Discounts and other Interesting Tips. We won't SPAM or SHARE your Email Address with anyone.
YOU CAN ALSO SEARCH FOR YOUR DESIRED TOPICS:
Thank you for reading! We welcome and appreciate your comments, but at the same time, make sure you are adding something valuable to this article. If you have any serious queries, suggestions or anything related to this article, feel free to share them, we really appreciate that.
But, if your blog comments are a random "Thank you", "Useful Post", or anything that doesn't actually upscale the article, then we'll be removing them and it won't be appeared below. Thanks for understanding and thanks for connecting with us. If you want to give us any feedback or report any errors, you can kindly contact us and we'll revert back soon.
- Comments
- Facebook Comments
- Comments
Do you have any queries? Want to share something?
55 Comments
Facebook Comments
Varinder Pal Singh
Great Tutorial very informative post. Thanks for sharing.
Saket Jajodia
I use JS and Meta tag to redirect my old blogspot blog to WP self hosted blog.. it works great for me.. But one thing is have to set 301 for each post so it get 301 to correct place..
Taj
private void Page_Load(object sender, System.EventArgs e)
{
Response.Status = “301 Moved Permanently”;
Response.AddHeader(“Location”,”http://www.google.com”);
}
Nisha Shah
Easy To Understand . Helped me alot. Big thanks for sharing.
Vinayak Nagri
Well, I don’t need it but still… thanks for sharing π
Karan
Well this is an essential feature if you want to move your blog to a new domain without losing the value you have earned to your current blog.
vicky sadhu
i agree with you karan!
sonu
just used htaccess method on a blog. need some tips on using .htpswd and how to block a country using htaccess.
Charlie Lapena
It is important to redirect the website to e able to know if there are some problems that had occurred. In this way, the site will be fixed.
Saikrishna
Very Easy To Understand And Thanks For The Trick π
It Helped Me
Have A Nice Day…!
Tech Junoon
I believe PHP Redirect is the best and easiest idea.
EasyMakesMoney.com
Thanks. Very good tips
sudharsan @ technoskillonline
It’s must for all bloggers to redirect broken page…
.-= sudharsan @ technoskillonline’s last blog…Win Dell Inspiron Laptop Free β Sizlopedia Contest =-.
Senthil Ramesh
Simple and easy Bro. I used it with WordPress plugin.
aks
yeah php works far better then any plug in cause plug in is a combination of php and javascript in most of the case.
S.Pradeep Kumar
Yeah.. for me PHP and HTML works pretty fine.. π
Will
Thanks Pradeep, that’s useful information you’re giving out about redirection
Cheers
Will
P.S: Please enter the BRIANWAVE (#BlogEngage) contest !
S.Pradeep Kumar
Count me in for the contest bro.. π
Uttoran Sen
thanks for posting a complete guide on re-direction, very useful. i use the re-direction plugin for wordpress, its an easy and quick way to re-direct pages on the same blog π
S.Pradeep Kumar
Yup.. but many ppl. also prefer plugins.. but I prefer this only! π
Rajesh Kanuri @ TechCats
php redirect is far better when compared to plugins…
Ruchi
I was looking for Php Redirect Syntax just trying to learn, and found it here, thanks for sharing the information.
S.Pradeep Kumar
Cool Ruchi..glad you found this article in my blog.. cheers! π
Rajesh Kanuri
looking for the similar article.. kudos…
S.Pradeep Kumar
Glad this article helped you buddy ! π
Millionaire Acts
Wow! Your blog site is very much helpful for not techy guys like me. I think I shall visit this more often. No wonder your blog became popular with a fast rising alexa rank of 136K. Congrats!
S.Pradeep Kumar
Thanks for the kind words buddy ! π
Glad to have you in this community ! π
Stay Connected ! ..
Sarang Dravid
Hey Pradeep! nice and complete post regarding the topic! inspite to help! I remember there’s a plugin for wordpress direction for permanent 301 url redirection wid name Link juice keeper i guess!!
search bout it for more info ^_^ …
S.Pradeep Kumar
Hey thanks for sharing that Sarang ! π
Even though I’m a plugin minimalist, I’ll try this plugin ! π
Class of 2013
Pradeep Kumar
Good list, Very useful redirect code, one person asked how to redirect joomla?..same issues for me, please help me…
S.Pradeep Kumar
Buddy. I’m not that much familiar with Joomla, but I used to experiment with .htaccess ! π
Check the comment I made to Web Design Chennai for solution ! π
S.Pradeep Kumar
@ w.Rana :It is peculiar to see this type of error buddy ! π
Can you give me the link of the sites used for redirection.
And you can also try this.. but I’m not recommending it.. you can use this if you are in urgent situation.. in the PHP redirect code.. use the site to be redirected same as the original site ! π
It is worth a try buddy ! π
Web Design Chennai
Good comments..i love this
S.Pradeep Kumar
Thanks mate ! π
Forming an interactive community here .. thanks for joining ! π
Web Design Chennai
Hi Pradeep kumar
How to 301 Redirect in Joomla, Please help me…
S.Pradeep Kumar
I'm not that much familiar with Joomla ! but the below steps will work ! π
Go to your .htaccess file and paste this code after <strong>#Rewrite Base</strong> and before the <strong>Joomla Core SEF section</strong>.
<code>########## Begin – Add www prefix to domain
#
RewriteCond %{HTTP_HOST} ^josephleonwebdesign.com [NC]
RewriteRule ^(.*)$ [R=301,L]
#
########## End – Add www prefix to domain</code>
<strong>References :</strong>
1. How to Make a 301 Redirect in Joomla (non WWW pages)
2. <a href="http://mixeduperic.com/open-source-software/how-to-redirect-old-joomla-or-mambo-dynamic-urls-with-htaccess.html">How To Redirect Old Joomla or Mambo Dynamic URLs with htaccess </a>
Himanshu
Nice blog and very nice tutorial, seems i will learn lot of things here.Keep writing like this.
S.Pradeep Kumar
Thanks for the compliment buddy ! π
Armawan
It’s good post. But i have problem to redirect 301 for my blog. Can you help me how to redirect 301 from www to become without www. on bloger? (example: redirect 301 http://www.mysite.blogspot.com to http://mysite.blogspot.com)
S.Pradeep Kumar
I added @ the bottom of this post about HTML redirect.. you can try that .. ! π
JakeI Web Journey
Very informative post. I have been trying to do this for a while but have been procrastinating. You make it seem easy!
S.Pradeep Kumar
Glad it helped you buddy ! π
HΓ©ctor | Blogging Diary
In addition to your post, 301 redirects are specially useful to minimize traffic loss when moving your site to a new domain (as I did a few days ago).
Hey, great theme!! Is this custom-designed? Never seen it before!
S.Pradeep Kumar
Yeah ! One of the main use ! π
I customized a bit ( little bit ) only !
Theme Name – Revolution (now Studiopress) church ! π
HΓ©ctor | Blogging Diary
Revolution Church – Now that you mention it, yes it is xD Nice work!
S.Pradeep Kumar
Thanks Hector ! ..
Glad you liked it ! π
Anish K.S
I need to redirect for only Page not found cases, can please tell how to set it ?.
S.Pradeep Kumar
Create a .htaccess file and paste this code :
ErrorDocument 404 /index.php
And upload it to public_html or htdocs folder of your website ! π
Anish K.S
Thanks Pradeep, i will check it. the PHP Redirect, i will contact you for assistance. π
S.Pradeep Kumar
I’m always Happy 2 Help buddy ! π
Contact me anytime… ! Cheers !
w.Rana
This is very interesting mate, but I have a question regarding the 301 redirect:
Is it possible to actually totally remove it? I created an index.php file with 301 redirect code in it for a website, but then later on needed to remove it, and I’ve been trying to do so by deleting the index.php file and also adding a new file without any success..is there any way of totally stopping/removing the redirecting of the site?
I’ll appreciate if you can reply π
Thank you
S.Pradeep Kumar
Buddy may I know what type of Redirect code you used ? PHP ? HTML ? π
Cheers !
w.Rana
thnx for the reply mate, it was a php redirect – like the one you’ve got in your list above.
cheers!
W.R
Nihar
Great thanks for this tutorial. I didn’t know about this.
S.Pradeep Kumar
Hey. Thanks for your comment Nihar !
I’m learning some codings now-a-days . So I tried my hands on posts like these ! π