Results 1 to 4 of 4

Thread: 301 redirects

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    just me duncan drennan's Avatar
    Join Date
    Jun 2006
    Location
    Cape Town
    Posts
    2,642
    Thanks
    119
    Thanked 94 Times in 77 Posts

    301 redirects

    I was never really quite sure how to do a 301 redirect and was never successful when trying to use cPanel, but I have finally got it working as I would like

    Let's back up a second.....what the heck is a 301 redirect? A 301 redirect permanently redirects a certain url to another url. There are a couple of reasons this could be useful, but the reason I want to do it is to ensure that all queries to my website land up at the same URL.

    I have two domains, engineersimplicity.com and engineersimplicity.co.za. Both domains point to the same content. This can potentially be a bad thing from a SEO perspective. I always want the search engines to use a particular domain, and that is www.engineersimplicity.com.

    So, by setting up the correct 301 redirects browsers will now always land on www.engineersimplicity.com, even if they typed in engineersimplicity.com, engineersimplicity.co.za or www.engineersimplicity.co.za. This is good for me, for the website users and for the search engines.

    Here are the instructions for setting up 301 redirects. I did it using the .htaccess file which is available on all Apache web servers.

    Here is the code I added to the .htaccess file (change yourdomain to your domain )

    PHP Code:
    Options +FollowSymlinks
    RewriteEngine on
    rewritecond 
    %{http_host} ^yourdomain.com [nc]
    rewriterule ^(.*)$ http://www.yourdomain.com/$1 [r=301,nc]
    rewritecond %{http_host} ^yourdomain.co.za [nc]
    rewriterule ^(.*)$ http://www.yourdomain.com/$1 [r=301,nc]
    rewritecond %{http_host} ^www.yourdomain.co.za [nc]
    rewriterule ^(.*)$ http://www.yourdomain.com/$1 [r=301,nc] 
    [EDIT] This still isn't working quite how I would like it to. If I go to a specific page it stays on that domain, rather than going to the other domain. I'll update this when I figure it out - or does someone here have some tips? Whoops, scratch that, it does work properly.
    Last edited by duncan drennan; 24-Mar-08 at 05:52 PM. Reason: update
    [SIGPIC]Engineer Simplicity[/SIGPIC]
    Turn ideas into products | The Art of Engineering blog

Tags for this Thread

Did you like this article? Share it with your favourite social network.

Did you like this article? Share it with your favourite social network.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •