PaulSpoerry.com

Social Media, technology, and geeky stuff for your brain.

  • Home
  • About
    • Privacy Policy
  • Categories
    • Google+ Posts
    • Site news
    • Tech
      • Android
      • Apple
      • Chrome
      • Gadgets
      • Hacking
      • Linux
      • OSX
      • Privacy
      • Web Life
        • Bittorrent
        • Facebook
        • FireFox
        • GMail
        • Google
        • Google+
        • Twitter
        • WordPress
        • Windows
          • Windows 7
    • Google+: Getting Started Guides
    • Games
    • Meditation
    • Politics
    • Science
    • That’s freakin hilarious
  • Code
    • FreeImageZoom
    • Post Editor for Google+™
    • The Plus Editor
  • Contact
You are here: Home / Tech / 301 Redirect: How to create Redirects and allow Subdomains

301 Redirect: How to create Redirects and allow Subdomains

August 23, 2011 by Paul Spoerry 10 Comments

Using a 301 redirect is the most efficient and Search Engine Friendly method for webpage redirection. Here’s how you can always redirect to the WWW version of your site while maintaining the use of subdomains.

htaccess 301 redirectRedirection is a way to forward users and search engines to a URL other than the one they originally requested. A 301 redirect  indicates to the search engines that a page has permanent moved. An issue you may run into with search engines is that www.mysite.com and mysite.com appear the same; this can lead the search engines to believe that there is duplicate content on your site. Whenever content on a site can be found at multiple URLs, it should be canonicalized for search engines. An example of how your content can appear to be duplicate is if your www and non-www versions of your site go to the same article. For example, if both of the following actually point to the same article, you need to implement a 301 redirect:

http://www.mysite.com/myreallycoolarticle

http://mysite.com/myreallycoolarticle

When both links contain the same content search engines might not know which version to include/exclude from their index or which version to rank for query results. The bottom line is that having both available can  hurt your SEO rankings. By using a 301 redirect you essentially tell the search engines to always use one over the other. Doing so means that the two pages (while technically the same) no longer compete with one another for ranking.

If you’d like to identify if you have duplicate content issues I’d recommend reading over this excellent article at Yoast.com. Yoast is considered an SEO expert and his article on duplicate content outlines simple ways to use Google Webmaster Tools to see if you’re being double indexed. If you’re curious about the details of how Google responds to 301 redirects just start reading Matt Cutt’s articles on 301’s, SEO, etc. He’s the man in charge of the Search Quality group at Google; he specializes in search engine optimization.

It turns out doing a 301 redirect is pretty simple, the primary rule to keep in mind is that you need to pick one or the other. Either always use WWW or never use WWW. I chose to use WWW, just because I always have. Some will argue that a non-WWW version looks better because the URL is shorter, and while visually that’s true, it won’t make a difference to the search engines.

You can find a plethora of examples of 301 redirects all over the net; so I won’t show a bunch of examples. A simple Google query will find you a ton of them. The problem I ran into is that I wanted to maintain my www but I ALSO use subdomains. Every example I found would redirect ALL non-WWW traffic to the WWW version of my site. One reason I use subdomains is so that I can place my images on images.paulspoerry.com and my page content on www.paulspoerry.com. By default the images of your site are hosted in the same domain as your content and this will slow down your page speed. Why? Almost all browsers create a maximum of two-four connections when downloading a page from your server. So if your page contains more than one image hosting those images in another another domain will allow a browser to download them in parallel with your main domain.

The solution to 301 redirects to WWW, that maintains the use of a subdomain is the following:

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.yourdomainname\.com [NC]
RewriteCond %{HTTP_HOST} !^([^\.]+)\.yourdomainname\.com [NC]
RewriteRule (.*) http://www.yourdomainname.com/$1 [R=301,L]

The code above tells the server to indicate a permanent redirect of all non-WWW traffic to it’s WWW counterpart while allowing the use of subdomains. So “https://paulspoerry.com/myarticle” will always go to “https://www.paulspoerry.com/myarticle”. It will not modify the request if a subdomain (ex: http://images.paulspoerry.com) is present. FYI, the [NC] is important as it specifies that case isn’t important. It tells incoming requests that “PaulSpoerry.com” (mixed case) and “paulspoerry.com” (lower case) are the same.

So there you go, add the above to your .htaccess file via FTP or CPanel, replacing “yourdomainname” with YOUR domain name. With the rules above you’ll be able to redirect non-WWW requests to it’s WWW counterpart while maintaining the use of subdomains. Once you’ve made the change you can test your redirection with Search Engine Friendly Redirect Checker. 

Filed Under: Tech Tagged With: 301 redirect, cheatplaza.nl, from, SEO, traffic

About Paul Spoerry

I’m a groovy cat who’s into technology, Eastern Thought, and house music. I’m a proud and dedicated father to the coolest little guy on the planet (seriously, I'm NOT biased). I’m fascinated by ninjas, the Internet, and anybody who can balance objects on their nose for long periods of time.

I have a utility belt full of programming languages and a database of all my knowledge on databases... I practice code fu. Oh, I've also done actual Kung Fu, and have a black belt in Tae Kwon Do.

I run. I meditate. I dance. I blog at PaulSpoerry.com, tweet @PaulSpoerry, and I'm here on Google+.

I'm currently work for IBM developing web enabled insurance applications for IBM and support and develop a non-profit called The LittleBigFund.

Comments

  1. mllee pet says

    March 24, 2012 at 8:22 am

    Thank you for this article:D I finally solved my problem!

  2. Paul Spoerry says

    March 24, 2012 at 8:46 am

    Glad it helped… took me FOREVER to track how to maintain my www but I ALSO use subdomains! Glad it helped!

  3. mike says

    May 8, 2012 at 1:01 am

    thanks! that is what i was looking for!

  4. Paul Spoerry says

    May 8, 2012 at 6:44 am

    You’re most welcome Mike. I know it took me a while to figure out how to do this and maintain the use of subdomain(s). Glad it helped!

  5. Barry says

    August 4, 2012 at 5:49 pm

    PS: Mind fixing the )(*&)& url (forgot the slashes…)? Thanks.

  6. Paul Spoerry says

    August 5, 2012 at 1:07 pm

    Hey Barry… I’m not 100% because I do the opposite…. only because I started that way and stuck with it. If I setup a new one today I’d go with a non-WWW version. That said this below should work to always redirect to a non-www domain and I think is a bit simpler.

    RewriteCond %{HTTP_HOST} !^www\.
    RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

  7. hardeepasrani says

    October 23, 2012 at 2:04 pm

    i purchased a domain from BigRock and hosting it on Blogger and wanna know how i can redirect any subdomain to any external url like my twitter profile….thanks :p

  8. Simon says

    May 23, 2014 at 2:33 pm

    Hi Paul,

    thanks a lot, exactly what I searched for quite a while!

    Cheers
    Simon

  9. Paul Spoerry says

    May 23, 2014 at 5:25 pm

    Glad to have helped Simon!

  10. what does the inside of a disposable cbd pen look like says

    June 15, 2022 at 2:50 pm

    Good Afternoon everybody ! can anyone advise where I can buy Canna River CBD Tincture Full Spectrum Peppermint 1000mg 5000mg?

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Copyright © 2023 · Epik on Genesis Framework · WordPress · Log in