301 Redirects To the Preferred Domain - How To?

by zendot
9 replies
  • SEO
  • |
Hello.

Google says to set our preferred domain (https://support.google.com/webmasters/answer/44231).

After we do this, they recommend this:
"Once you've set your preferred domain, you may want to use a 301 redirect to redirect traffic from your non-preferred domain, so that other search engines and visitors know which version you prefer."

So, for example, my preferred domain is https://domain.com. Now I need to redirect other versions (http://, http://www., https://www.) to my preferred domain.

How can I do this? By modifying the .htaccess file or by using cPanel?

Thanks.
#301 #domain #preferred #redirects
  • Profile picture of the author bertieallsorts
    Firstly use Google Webmaster tools "set preferred domain" That lets google know which version of your website to display on search results.

    Then you need to implement it server side - simply done by using 301 redirect from cpanel - Redirects

    Once executed, check the redirects work, then do a "fetch as " in webmaster tools - invite google back to crawl the newly updated urls.

    and your done.

    Bertie
    {{ DiscussionBoard.errors[11171549].message }}
    • Profile picture of the author zendot
      Thanks for your reply!

      I added all 4 versions to GWT and set the preferred domain to non-www (just domain.com) for all domains.

      How do I make a redirect in cPanel? Here's an image from the "Redirects" settings.



      Are these settings correct?

      Thanks.
      {{ DiscussionBoard.errors[11171858].message }}
  • Profile picture of the author BreezeHost
    You can set 301 redirections by using cPanel.

    Hope this helps you
    {{ DiscussionBoard.errors[11171919].message }}
  • Profile picture of the author bertieallsorts
    That screen shot is pretty much ready to go - enter the domain you want to redirect in the top line ( so you want to go from www to non www. so enter your WWW domain in the box below permanent 301

    bottom box, simply insert the domain you want it to be, in your case Yourdomain.com (no www.)

    do that for each url

    remember to drop either https, www. etc for the bottom box on every domain which extension you want to change

    the check the redirect is working

    let me know how you get on

    Bertie
    {{ DiscussionBoard.errors[11172072].message }}
    • Profile picture of the author zendot
      Thanks for your valuable info!

      Upon checking with SiteGround support tech, they've confirmed that if I tick the "Force SSL" option in their WordPress plugin, all traffic is redirected to https://mydomain.com.

      I've checked the .htaccess file and a redirect was added. I also used redirect checking service and everything works fine.

      So basically, because I use SiteGround hosting and the "Force SSL" option, redirects are taken care of automatically. Sweet!

      That leaves me with one more question.

      We need to add https://, https://www., http:// and http://www. variants of our domain to Google Search Console (Google Webmaster Tools).

      Since now all the traffic is redirected to https://, do we need to submit a sitemap only for that domain or for all domains?

      Thanks.
      {{ DiscussionBoard.errors[11172580].message }}
  • Profile picture of the author Maple Labs
    it can be change through .htaccess
    {{ DiscussionBoard.errors[11172589].message }}
  • Profile picture of the author bertieallsorts
    Ideally you would submit the individual domains and sitemaps to google and verify each one - once google crawls your website it will instantly know that all versions of your website will resolve to the one you redirected it to and rank that version.

    What i usually do is add all my versions to webmaster tools, verify them all, and do a fetch as on each domain

    i find it better to have all versions within the console and a sitemap submitted for each.

    Bertie
    {{ DiscussionBoard.errors[11173356].message }}
    • Profile picture of the author zendot
      Perfect, thank you!
      {{ DiscussionBoard.errors[11173612].message }}
  • Profile picture of the author websetters
    How to Implement 301 Redirects Using .htaccess for Apache
    Make sure you have access to your server and your Apache configuration file, and that you can use your .htaccess files. The ability to use .htaccess files will reside in a command called "Allow Override" in the Apache config file. If you do not have this access, you'll have to first call your hosting company and get access.

    Once you know that you have access to this file, your next step is to locate it. The .htaccess file is a control file that allows server configuration changes on a per-directory basis. It controls that directory and all of the subdirectories contained within. In most cases, this file will be placed in the root web folder for your site. If there's no .htaccess file present, create one.

    To begin using the .htaccess file to redirect page(s) on your site, open up your FTP and log in to your site. Work your way into in the root web folder in order to access your .htaccess file.

    (Note: The dot in .htaccess makes it a hidden file, so make sure your FTP browser is enabled to view hidden files.)

    When you start editing the file, use a UNIX style text editor rather than Notepad. Typically, an HTML editor or code editor such as TextPad works just fine. To 301 redirect pages using the .htaccess file, you will add a line to the file that tells the server what to do.

    To 301 Redirect a Page:

    RedirectPermanent /old-file.html http://www.domain.com/new-file.html

    To 301 Redirect an Entire Domain:

    RedirectPermanent / http://www.new-domain.com/

    Once you have inserted the commands to 301 redirect your pages, you need to make sure that there is a blank line at the end of the file. Your server will read the .htaccess file line by line, which means at some point you'll need to throw it an "endline" character to signify that you're finished. An easy way to do this is to put a blank line at the bottom of the file.

    How to Do a 301 Redirect Using IIS on a Microsoft Windows Server
    Navigate your way to Internet Information Services (IIS) Manager, which is found with Administrative Tools within the Start menu. From there, you will find a panel on the left-hand side that lists all your sites. Choose the site you want to work on.

    Once you select it, several modules come up. Verify the URL Rewrite module is present. If it is not, you can install it here.

    Once you have it, double-click to open the module. On the right-hand side, you will see an option to Add Rules. Click it and then select Blank Rule under the Inbound Rules section. Hit OK. This will take you to an Edit Inbound Rule page. Type a name for the rule, such as Old Domain Redirect or Old Page Redirect.

    Go to the Match URL Panel. Set the requested URL at "Matches the Pattern" and then Using as Regular Expressions. Now you will specify if you're redirecting a single page, a group of pages, or an entire domain:

    To redirect a single page, type in the page name under Pattern. For example, if we were redirecting this blog post, we would input blog/how-to-properly-implement-a-301-redirect/ in the Pattern field.
    To redirect the entire site, we would input (.*) in the Pattern field.
    To redirect all the pages on BruceClay.com within the SEO folder, we would input seo/(.*)
    Make sure "ignore case" is checked.

    Skip down to the action panel and select Redirect within the Action Type drop-down menu. In the Action Properties, type in the new URL. If it's a single page, input the single page. If it's the entire domain or a group of pages, type the new destination with a back reference, which is {R:0}. The back reference will keep all page URLs intact with the new domain.

    For example, if we were changing BruceClay.com to BCI.com, we would input http://www.bci.com/{R:0}

    If you use tracking parameters and you want them to carry through, check Append Query String.

    In the Redirect type field, select Permanent (301).

    Click Apply at the top right in the Actions column to save the redirect.

    (If you want to review the redirect, hit back to rules in the Actions column.)

    After you save this redirect, the rules you created are saved into the web.config file, which you can edit in the future.


    Alternative Methods to Implement a 301 Redirect
    If you don't have access to your .htaccess file or your Windows Server Administration Panel, you can still implement 301 redirects with code on your old pages. If your pages are in PHP, ASP, Java, or any other language that allows you to modify response headers, simply place code at the top of each page to do the permanent redirect.

    Redirecting pages is just ONE skill an SEO has to know. At BCI, we help clients with not just the how-tos, but also the strategy questions they need to optimize their online revenue. Want to explore how we can help you? Request a conversation or call us today.


    Why You Might Need to Implement a 301 Redirect
    There are many times a 301 redirect makes sense. Here are a few of the most common:

    You're changing your entire root domain.
    You want to reorganize pages by changing or removing a directory.
    Let's say CNN posted a link to this blog post, but the URL was incorrect. We'd still want to capture the traffic that is going to a 404 page. So we'd put in a 301 redirect to direct users from the bad link to the right URL.
    You want a vanity URL.
    {{ DiscussionBoard.errors[11173505].message }}

Trending Topics