SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict Jakob's Avatar
    Join Date
    Aug 2002
    Location
    Denmark
    Posts
    270
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Best way to permanently redirect

    I have set up a webshop at shopify.com. Let's say my store is located at example.shopify.com.

    I would like to run it on my own unique domain - let's call it example.com.

    I've now made a CNAME record to point www.example.com to example.shopfy.com - which works just fine.

    My problem is that example.com (without "www") does not work.

    My question is what would be the best way to permanently redirect "example.com" to "www.example.com"? I'm looking for the best solution when also taking SEO into account. I don't want to upset Google :-)

    Thanks in advance
    Learn more about Solar Panel Installation

  2. #2
    SitePoint Member
    Join Date
    Sep 2012
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Write this code in your .htaccess

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

  3. #3
    SitePoint Addict Jakob's Avatar
    Join Date
    Aug 2002
    Location
    Denmark
    Posts
    270
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks alisaparkar,

    Looks like a good solution. Do you know if this would also be accepted by Google and the other search engines?
    Learn more about Solar Panel Installation

  4. #4
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    8,895
    Mentioned
    138 Post(s)
    Tagged
    2 Thread(s)
    Quote Originally Posted by Jakob View Post
    Thanks alisaparkar,

    Looks like a good solution. Do you know if this would also be accepted by Google and the other search engines?
    Yes, 301 redirects indicate to google, "Please look over here instead.", which Google happily accepts.

    Although the code above works fine I'd suggest a few minor tweaks to make it a bit more efficient.

    Code:
    Options +FollowSymlinks
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^example\.com [NC]
    RewriteRule .? http://www.example.com%{REQUEST_URI} [L,R=301]
    Rémon - Hosting Advisor

    Minimal Bookmarks Tree
    My Google Chrome extension: browsing bookmarks made easy

  5. #5
    SitePoint Addict Jakob's Avatar
    Join Date
    Aug 2002
    Location
    Denmark
    Posts
    270
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you both.

    I'll try it out.
    Learn more about Solar Panel Installation


Bookmarks

Posting Permissions

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