301 .htaccess redirect

301 .htaccess redirect

July 15, 2012

What is 301 redirect?

People access your site like http://yourdomain.com or http://www.yourdomain.com and they get same result but  both url are different for search engine. It means  http://yourdomain.com or http://www.yourdomain.com  are different domain. 301 redirect is the best method to preserve your current search engine rankings when redirecting web pages or a web site.  To implement a 301 redirect for websites that are hosted on servers running Apache, you'll need access to your server's .htaccess file. If your site is hosted on a server running other software, check with your hosting provider for details.

What is a .htaccess file?

The .htaccess file contains specific instructions for certain requests, including security, redirection issues and how to handle certain errors. When a visitor/spider requests a web page, your web server checks for a .htaccess file. You can create the .htaccess file using notepad. Just open the notepad, insert you code and save by putting "File Name" as .htaccess and "Save as type" should be set to "All" 301 htaccess redirect If you want to redirect http://yourdomain.com to http://www.yourdomain.com, first you've to enable the  mod_rewrite enabled on your server you can put below code in your .htaccess file: Options +FollowSymLinks RewriteEngine on RewriteCond %{HTTP_HOST} ^yourdomain.com RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [R=permanent,L] or this:  Options +FollowSymLinks RewriteEngine On RewriteCond %{HTTP_HOST} ^yourdomain.com$ [NC] RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [R=301,L]

Related Posts

from my blog


Hire Full Stack Developer: Unlocking the Power of Versatility

April 5, 2024

Why hire full-stack programmers? What exactly is Full Stack Development? Developers who are full stacks can manage all aspects of software development including managing databases, designing user interfaces or configuring...

Why Should Your Hire Freelance Web Developer: The Top Benefits

May 17, 2022

When developing a website or an app, there are two major ways to do it - outsource the job to a web development company or hire a freelancer to get...

7 Reasons Why You Should Hire A Freelancer Developer Over A Development Team

May 13, 2022

Are you confused between hiring a freelance web developer vs a development team? Then we suggest getting a freelancer over a team! Why? Because they are much better workers than...