Quantcast
Viewing latest article 1
Browse Latest Browse All 7

301 .htaccess redirect

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”

Image may be NSFW.
Clik here to view.
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]


Viewing latest article 1
Browse Latest Browse All 7

Trending Articles