Popular Google Pages:
◕ পৃথিবীর বিভিন্ন সভ্যতার রোমাঞ্চকর কথা Details..
◕ Send your story to RiyaButu.com and get ₹ 500/- Details..
◕ Bengali Story writing competition. Details..
This article is regarding 301 Redirection with .htaccess File.
Last updated on: 28th November 2016.
◕ What is 301 redirection?
- 301 redirection is a permanent redirection from one URL to another. In other word 301 status code means that the Page has permanently moved to a new location.
Suppose in your Website you have changed the name of a file or you have moved a file from one folder to another. Now the URL of the old file has changed.
In this situation Search Engine may show the old URL in it's search result. As the Search Engine may have already indexed that URL and that file before, So if the User click on that URL in the rearch reasult, he will get nothing but error. As this old URL has no existance.
In such a situation you will lost your SEO ranking for that particular Page. Also Search Engine will show crawl error. To maintain the ranking of that Page and to redirect the User to the new URL, 301 is the safest option.
In other word we can say the code "301" means "moved permanently with ranking". This is the best way to ensure that Users and Search Engines are directed to the correct Page.
◕ 301 redirects are very useful and importent for the following situations:
■ 1) If you have moved your Website from old Domain to a new Domain.
■ 2) If you change the name of a file or files.
■ 3) If you change the location of a file or files.
■ 4) If you have different Websites and you want to redirect User and Search Engine to a particular Site.
For an example, you have both www.riyabutu.com and riyabutu.com . You want to redirect all User to riyabutu.com , not in www.riyabutu.com . So use 301 redirection.
301 redirection is easy to implement. In the most case the 301 redirection is done by .htaccess file.
The .htaccess file is a simple text file in the Root Directory of Our Site. Normaly it exists as a hidden file.
If you don't have this file in your Root Directory, you can easily create/edit a .htaccess file using any plain-text editing like Notepad or Notepad++ .
But be careful while creating and editing .htaccess file . Because .htaccess file is very powerful. Even a simple syntax error (like a missing space) can prevent your Site to display correctly. So always take a back up of this .htaccess file before editing.
Create an empty text file using a text editor such as notepad or notepad++ and save it as htaccess.txt .
We should save it as htaccess.txt , because by default many operating systems don't allow or unable to
read or view .htaccess file .
After uploading the file to the Root Directory we can rename the file as .htaccess .
After rename you can edit this file easily.
The sign # is used for comments in .htaccess file.
1) In the following code we redirect two Pages.
# This is a comment.
# This is another comment.
Redirect 301 /oldfile.html http://riyabutu.com/tripura/newfile.html
Redirect 301 /folderName/oldfile.html http://riyabutu.com/india/newfile.php
2) In the following code we redirect old Domain to new Domain.
# This is a comment.
Redirect 301 / http://riyabutu.com/
Please note that:
301 redirection will not redirect any email from your old Domain to your new Domain.
you can also redirect a Page using PHP.
Just open the old file, delete all the content on it and write the
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://riyabutu.com/newPage.html" );
Please note: Though we can redirect a Page with PHP but .htaccess is the best for parmenent redirection.
◕ All the Best!
◕ Related articles:
► How to make XML Sitemap?
► Robots.txt Fetch Error
► How to find URL of my Twitter Account?
► Difference between .html & .htm
► List of wildcard used in MySQL
► MySQL match a string
Top of the page