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. Web Design
    4. Do I need to 301 redirect www.domain.com/index.html to www.domain.com/ ?

    Do I need to 301 redirect www.domain.com/index.html to www.domain.com/ ?

    Web Design
    5 5 5.0k
    • 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.
    • Small_Business_SEO
      Small_Business_SEO last edited by

      So, interestingly enough, the Moz crawler picked up my index.html file (homepage) and reported duplicate content, of course. But, Google hasn't seemed to index the www.domain.com/index.html version of my homepage, just the www.domain.com version. However, it looks like I do have links going specifically to www.domain.com/index.html and I want to make sure those are getting counted towards my overall domain strength.

      Is it necessary to 301 redirect in the scenario described above?

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

        Yes, you will want to redirect it. Be careful though as a lot of times this isn't done correctly and creates a loop. There are multiple ways to do this including but not limited to DirectoryIndex or a RewriteRule

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

          Yep,

          This code inside your .htaccess file should fix that.

          ``RewriteEngine On 
          RewriteBase /` RewriteRule ^(.*)index\.(html|php)$ http://%{HTTP_HOST}/$1 [R=301,L]`
          
          Hope it helps,
          Don
          
          1 Reply Last reply Reply Quote 2
          • MindlessWizard
            MindlessWizard last edited by

            I would recommend you to do that.  Homepage may have different versions  depending on the CMS you are using.

            index.htm index.html

            index.php

            So as @donford mentioned you can fix that with .htaccess

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

              Hi,

              I tested the code mentioned above:

              RewriteEngine On
              RewriteBase /
              RewriteRule ^(.*)index.(html|php)$ http://%{HTTP_HOST}/$1 [R=301,L]

              It works well for index.php, but not for XX-index.php. The site where I tested this code is bilingual, so there is also a GR-index.php file and the above code redirects it to the root domain as well.

              Also, another problem is that the code above causes the redirection of index.php inside any directory. For example, http://domain.com/directory/index.php is redirected to http://domain.com/directory/

              How can I avoid this and keep only a "basic" redirection of http://domain.com/index.php to http://domain.com?

              Yannis

              1 Reply Last reply Reply Quote 0
              • 1 / 1
              • First post
                Last post
              • We added hundreds of pages to our website & restructured the layout to include 3 additional locations within the sub-pages, same brand/domain name. How long could Google take to crawl/index the new pages and rank the keywords used within those pages?
                Roman-Delcarmen
                Roman-Delcarmen
                0
                2
                48

              • 302 redirects, canonicalise or redirect (301)?
                eLab_London
                eLab_London
                0
                5
                754

              • 301 htaccess redirect or 301 HTTP DNS Redirect
                OlegKorneitchouk
                OlegKorneitchouk
                0
                2
                1.4k

              • Blog.yoursite.com or yoursite.com/blog/?
                Francisco_Meza
                Francisco_Meza
                0
                4
                607

              • 301 Redirect from Old Domain to New Domain
                Chris.Menke
                Chris.Menke
                0
                2
                1.3k

              • Is it possible to redirect the main www. domain - but keep a subdomain active?
                edlondon
                edlondon
                0
                6
                2.8k

              • Http://www.domain.com/services/city or http://www.domain.com/city
                Landforce
                Landforce
                1
                5
                163

              • Show root domain (that is 301 redirected) in SERP?
                MoosaHemani
                MoosaHemani
                0
                7
                1.1k

              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