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. Redirect question

    Redirect question

    Technical SEO Issues
    6 3 513
    • 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.
    • seoug_2005
      seoug_2005 last edited by

      I would like to redirect  http://example.com/index.html to  http://www.example.com/

      Is the code below correct ?

      RewriteEngine on

      RewriteCond %{HTTP_HOST}^example.comRewriteRule (.*)

      http://www.example.com/$1 [R=301,L]

      RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index.html\ HTTP/

      RewriteRule ^index.html$ http://www.example.com/ [R=301,L]

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

        The first portion of your code seems correct, although the line breaks are a bit off in the post? We have a similar approach for forwarding non-www to www-pages.

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

        I've google a bit and found the following code:

        All in all, I would say your .htaccess code should be:

        RewriteEngine on
        RewriteCond %{HTTP_HOST} ^domain.com [NC]  
        RewriteRule ^(.)$ http://www.domain.com/$1 [L,R=301] 
        RewriteCond %{THE_REQUEST} ^.
        /index.html
        RewriteRule ^(.*)index.html$ http://www.domain.com/$1 [R=301,L]

        Best way to get an answer? Try uploading the .htaccess code and see if it works - if not, take it down again and correct the code. However the above should work I should think.

        -Rasmus

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

          Atul, I think the way Rasmus has it here is correct. The other day I came across a tool for 301's that will write for you.  FULL Disclosure is I have not used it yet. If you want to check it out, the site is

          http://seo-website-designer.com/HtAccess-301-Redirect-Generator

          Might be worth a try.

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

            Thanks Rasmus Olesan.

            1 Reply Last reply Reply Quote 0
            • seoug_2005
              seoug_2005 @RobertFisher last edited by

              Many Many Thanks Robert for the useful link.

              I tried the tool but it didn't generated the code as stated above. Have i missed something ?

              RobertFisher 1 Reply Last reply Reply Quote 0
              • RobertFisher
                RobertFisher @seoug_2005 last edited by

                I would go with the code the way Rasmus has laid it out for you. I will check out the tool and let youknow.

                1 Reply Last reply Reply Quote 1
                • 1 / 1
                • First post
                  Last post
                • 301 redirect file question
                  tretanto
                  tretanto
                  0
                  7
                  106

                • Redirect Question
                  Ray-pp
                  Ray-pp
                  0
                  2
                  67

                • Basic Redirection Question
                  Netrepid
                  Netrepid
                  0
                  2
                  100

                • One more redirect question
                  WhoWuddaThunk
                  WhoWuddaThunk
                  0
                  3
                  88

                • URL redirect question
                  AlanMosley
                  AlanMosley
                  0
                  8
                  165

                • 301 Redirect Questions
                  photoseo1
                  photoseo1
                  0
                  9
                  512

                • 301 Redirect Question
                  Yo_Adrian
                  Yo_Adrian
                  0
                  3
                  433

                • Redirect or not to redirect
                  AlanMosley
                  AlanMosley
                  0
                  7
                  458

                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