301 Redirection Using htaccess

The following post is about using redirection to keep your existing search engine ranking for content on an old domain. Here’s my story: I purchased multiple domains and by default set them to all direct to the same content (eg. document root). When I started my search engine optimization kick I realized that different domains got better search engine rankings than others – even on the EXACT same content. And google thought that I had more links from external sites than I actually did. Some of you might think that sounds good because there were more external links than there should be, but most of them were links to things I didn’t want high links to like my registration page, site search, etc.

 

I finally moved my sites to a new server and decided it was probably a good time to start segregating my domain content. I plan on retiring flamingcube.com sometime later in the year, so I’m trying to get the SEO results for it transitioned to the new server. I plan on using the other domains I have registered for completely new sites so I want to start getting all the content pushed over now so in a few months I can remove the redirects and start with new content.

Redirect Old domain to New domain

Simply create an .htaccess file in the root of your domains document root (often public_html) – this is the same place you would probably have an index.html file. Add the following text to the .htaccess file and save it. Make sure you replace newdomain.com with your new domain you want the content redirected to.

 Options +FollowSymLinks RewriteEngine on RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L] 

I should note that this method of redirection only works on servers that support the mod_rewrite apache module. This would typically just mean Apache servers with mod_rewrite installed, but you can get it working on IIS servers if you have a similar mod_rewrite module that can parse htaccess files.

 

Redirect www and other domains to proper domain

This is the next peice of my SEO kick. I’m testing out a new search component for Joomla called PixSearch that creates a search dropdown similar to Apple.com. It uses AJAX to send your request to the site search while you are typing and pulls up search results directly on the page. The only issue with this is the search module uses the joomla defined site domain to do the search. If you land on the page using a subdomain or other domain that points to the same document root the search will fail to execute to prevent XSS (cross site scripting) vulnerabilities.

 

Regardless, it’s probably a good idea to standards your domains and use the proper redirection. This updates search engines and makes it easier for coders to develop software.

 Options +FollowSymlinks RewriteEngine on rewritecond %{http_host} ^domain.com [nc] rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc] 

As with the other .htacess file, replace the domain names with your actual domain name.


Posted

in

by

Tags:

Comments

7 responses to “301 Redirection Using htaccess”

  1. Henrik Avatar
    Henrik

    I will try to change this domain issue in the next version.
    Just wanted to take a look on your progress on implementing pixsearch, seems you made it!

    Congratz! 🙂

  2. josh Avatar
    josh

    Henrik, thanks for the follow up. I should note that I decided not to port PixSearch from MooTools to Prototype. As MooTools is the Joomla 1.5 supported javascript framework, I decided to work with the comment component I am using and make some changes to it so it is more compatible with the MooTools framework.

    I didn’t include a link to the PixSearch site in the article, so here’s one: PixSearch Home ([url]http://labs.pixpro.net/[/url])

  3. SNVC Avatar
    SNVC

    This is definitely a good guide. Thanks for this. http://sn.vc

  4. Trancer Avatar
    Trancer

    I tried this but i could’t make it work… i am using wamp and the site is on local host. i put all types of redirects but still doesn’t work. Any ideeas? Thanks.

    Trancer

    [url]http://torrent.pussylane.net/[/url]

  5. Biju George Avatar

    Hi,

    I’m using a tool to crawl my web pages. And the tool says I’ve duplicate pages. The duplicates are below:

    1. http://www.lenvica.in/
    2. http://www.lenvica.in/index.php

    Is it necessary to redirect (1) to (2)?

    Thanks,
    Biju.

  6. SEO Expert Avatar

    Does anyone knows how to redirect 301 from the index.php to the root, but only for the main index.php

  7. Troll Avatar
    Troll

    Thank you for this great tutorial.

Leave a Reply

Your email address will not be published. Required fields are marked *