The Moz Q&A Forum

    • Forum
    • Questions
    • My Q&A
    • Users
    • Ask the Community

    Welcome to the Q&A Forum

    Browse the forum for helpful insights and fresh discussions about all things SEO.

    1. SEO and Digital Marketing Q&A Forum
    2. Categories
    3. Technical SEO Issues
    4. 301 Re Direct Question for www

    301 Re Direct Question for www

    Technical SEO Issues
    7 3 570
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as question
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • anoopbal
      anoopbal last edited by

      Can smeone check this code to make sure it is right so thaqt my site uses www always.

      RewriteCond %{HTTP_HOST} ^exercisebiology.com [NC]

      RewriteRule ^(.*)$ http://www.exercisebiology.com/$1 [R=301,L]

      I had the hostgators customer service personnel perform this. But I cannot get it to redirect. But he says it works.

      1 Reply Last reply Reply Quote 0
      • NakulGoyal
        NakulGoyal last edited by

        Try this in the .htaccess file. It should work fine for sure. You don't need to manually add your website name.

        <code class="htaccess" title="in your .htaccess file">RewriteEngine On
        RewriteCond %{HTTP_HOST} !^www.
        RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]</code>

        
        
        1 Reply Last reply Reply Quote 1
        • anoopbal
          anoopbal last edited by

          Thank you. Worked like a charm.

          Since we are on the topic, do you know how I can put a redirect for these pages: For every article, I have a few of these duplicate titles. I removed the pagination tags so it wont give out any more P's and N's But I am guessing I should do redirect. Should I ? **Here is an example of one article and  the URL's with page numbers. **

          /index.php/site/articles/does_testosterone_supplement_tribulus_work//index.php/site/articles/does_testosterone_supplement_tribulus_work/N12//index.php/site/articles/does_testosterone_supplement_tribulus_work/N1564//index.php/site/articles/does_testosterone_supplement_tribulus_work/N1568//index.php/site/articles/does_testosterone_supplement_tribulus_work/N1572/P12//index.php/site/articles/does_testosterone_supplement_tribulus_work/N1572/P18//index.php/site/articles/does_testosterone_supplement_tribulus_work/N1572/P6//index.php/site/articles/does_testosterone_supplement_tribulus_work/N16//index.php/site/articles/does_testosterone_supplement_tribulus_work/N4/P18//index.php/site/articles/does_testosterone_supplement_tribulus_work/N4/P6//index.php/site/articles/does_testosterone_supplement_tribulus_work/N8/P12//index.php/site/articles/does_testosterone_supplement_tribulus_work/N8/P6//index.php/site/articles/does_testosterone_supplement_tribulus_work/P12/N1572//index.php/site/articles/does_testosterone_supplement_tribulus_work/P12/N8//index.php/site/articles/does_testosterone_supplement_tribulus_work/P18/N1572//index.php/site/articles/does_testosterone_supplement_tribulus_work/P18/N4//index.php/site/articles/does_testosterone_supplement_tribulus_work/P18/N8//index.php/site/articles/does_testosterone_supplement_tribulus_work/P6/N1572//index.php/site/articles/does_testosterone_supplement_tribulus_work/P6/N4//index.php/site/articles/does_testosterone_supplement_tribulus_work/P6/N8/

          NakulGoyal 1 Reply Last reply Reply Quote 0
          • NakulGoyal
            NakulGoyal @anoopbal last edited by

            I see you have canonical tags in place. Considering that, I would suggest you are good. No need to setup any of those redirects. Canonical tags are in essence sort of 301's anyways, so you are all set.

            anoopbal Dr-Pete 3 Replies Last reply Reply Quote 1
            • anoopbal
              anoopbal @NakulGoyal last edited by

              Thanks!

              1. Can you show me how to do a redirect for for http://www.exercisebiology.comto http://www.exercisebiology.com/  I want to add the trailing slash.

              2. Also how to redirect  from http://www.exercisebiology.com/index.php

              to http://www.exercisebiology.com/.

              When I tried to redirect the index.php last time, I couldn't login to the forums. Everytime when someone tries to login to my forums, it takes them the to the home page. I did it through the hostgator CP. I am thinking someone could help me here.

              Thank you so much!

              1 Reply Last reply Reply Quote 0
              • Dr-Pete
                Dr-Pete @NakulGoyal last edited by

                Does your site use the "index.php" version of the page with parameters to handle logins? In that case, you can't 301-redirect the page across the board. You'd have to do it selectively (only for the version with no parameters), and that's going to take custom-coding. You'd probably be better off with a canonical tag, in that situation - it would keep Google from indexing the variants (including the login pages, which have no search value).

                1 Reply Last reply Reply Quote 0
                • anoopbal
                  anoopbal @NakulGoyal last edited by

                  Yea That's what I think.

                  I tried adding the traoling slash with 301 redirecet, but it didn't work.

                  RewriteEngine On
                  RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_URI} !(.)/$ RewriteRule ^(.)$ http://www.exercisebiology.com/$1/ [L,R=301]

                  This was the code I used. Can you tell me what is wrong please?

                  1 Reply Last reply Reply Quote 0
                  • 1 / 1
                  • First post
                    Last post
                  • 301 Re-direct help
                    regal_kyle
                    regal_kyle
                    0
                    5
                    93

                  • 301 permanent re-direct
                    GeorgeAndrews
                    GeorgeAndrews
                    0
                    8
                    265

                  • To 301 redirect or not to 301 redirect? duplicate content problem www.domain.com and www.domain.com/en/
                    Chris-CA
                    Chris-CA
                    0
                    5
                    456

                  • 301 re-directs to similar content, good idea?
                    AlanMosley
                    AlanMosley
                    0
                    5
                    346

                  • Penguin 301 Re-Direct
                    brightonseorob
                    brightonseorob
                    0
                    4
                    351

                  • Webmaster woes - should I re-direct or re-structure?
                    Danapollo
                    Danapollo
                    0
                    3
                    271

                  • Purchasing a site for a 301 Re-direct
                    dittoeffect
                    dittoeffect
                    0
                    6
                    670

                  • Is there a penalty for too many 301 re-directs?
                    wissamdandan
                    wissamdandan
                    0
                    5
                    583

                  Get started with Moz Pro!

                  Unlock the power of advanced SEO tools and data-driven insights.

                  Start my free trial
                  Products
                  • Moz Pro
                  • Moz Local
                  • Moz API
                  • Moz Data
                  • STAT
                  • Product Updates
                  Moz Solutions
                  • SMB Solutions
                  • Agency Solutions
                  • Enterprise Solutions
                  • Digital Marketers
                  Free SEO Tools
                  • Domain Authority Checker
                  • Link Explorer
                  • Keyword Explorer
                  • Competitive Research
                  • Brand Authority Checker
                  • Local Citation Checker
                  • MozBar Extension
                  • MozCast
                  Resources
                  • Blog
                  • SEO Learning Center
                  • Help Hub
                  • Beginner's Guide to SEO
                  • How-to Guides
                  • Moz Academy
                  • API Docs
                  About Moz
                  • About
                  • Team
                  • Careers
                  • Contact
                  Why Moz
                  • Case Studies
                  • Testimonials
                  Get Involved
                  • Become an Affiliate
                  • MozCon
                  • Webinars
                  • Practical Marketer Series
                  • MozPod
                  Connect with us

                  Contact the Help team

                  Join our newsletter
                  Moz logo
                  © 2021 - 2026 SEOMoz, Inc., a Ziff Davis company. All rights reserved. Moz is a registered trademark of SEOMoz, Inc.
                  • Accessibility
                  • Terms of Use
                  • Privacy