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. Best Redirect for old .htm extention to root ?

    Best Redirect for old .htm extention to root ?

    Technical SEO Issues
    10 4 1.1k
    • 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.
    • hfranz
      hfranz last edited by

      I have been trying to figure this out with different redirects but cannot seem to get this correct. Some of our forums link to pages that do not exist or are very old. They have (.htm) extension. I do not want to redirect the .htm to .php because the actual names of the link have changed too. What is the best code to redirect any link that has a .htm extention to the root domain? right now I have this code to redirect index.htm to the root, but that is all it works for. I think.

      RewriteCond %{THE_REQUEST} ^.*/index.htm

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

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

        <code>This should do the trick :)</code>
        

        <code>RedirectMatch 301 (.*).htm$ /</code>

        hfranz 2 Replies Last reply Reply Quote 0
        • hfranz
          hfranz @blu42media last edited by

          when i try that, the website does not load quick. It and when I click on a link it takes forever. But once I remove it, then it is fine.

          i tried adding this alone (removing the other code) and i also tried it with the other code.

          Any idea why?

          1 Reply Last reply Reply Quote 0
          • hfranz
            hfranz @blu42media last edited by

            that code actually breaks all my links. Currently all of our links are .php. I just want to redirect old links that have .htm to our home page.

            blu42media hfranz 2 Replies Last reply Reply Quote 0
            • blu42media
              blu42media @hfranz last edited by

              Okay... let's try adjusting that slightly:

              RedirectMatch 301 ^/(.*).htm$ /

              Another option, depending on how many .htm pages you need to redirect, is to place this in your .htaccess file in the directory where your .htm pages are located:

              <code>RedirectPermanent /oldpage.htm http://www.example.com/</code>
              
              1 Reply Last reply Reply Quote 0
              • StalkerB
                StalkerB last edited by

                Put the whole root domain in

                RedirectMatch 301 (.*).htm http://www.example.com/

                Works for me 🙂

                1 Reply Last reply Reply Quote 0
                • hfranz
                  hfranz @hfranz last edited by

                  none of the .htm pages exist. I just noticed a bunch of forums that link to us use the .htm extention. I am assuming these are very old pages. I noticed these links were broken in Google Webmaster Tools. So I want to redirect these old links to our home page. I just want them redirected, because I cant stand seeing these in Google Webmaster Tools. This code redirects every single page on my website now to the root domain.

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

                    I realize your focus is fixing your .htm issue, but I would like to make one suggestion. Start using friendly URLs which don't show an extension. It should be a win for your site.

                    hfranz 1 Reply Last reply Reply Quote 0
                    • hfranz
                      hfranz @RyanKent last edited by

                      Thanks! How do you name a file without an extention then? Is this done with a CMS ? I did not realize that extentions were bad. Do you think if I would redo our website soon using Wordpress or expression engine, do you think this may help our rankings too ?

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

                        Wordpress and other software either comes designed for SEO, or has plug-ins which offer SEO abilities.

                        They work by automating some tasks for you. For example, they can automatically canonicalize pages or use friendly URLs. Any SEO options you set up must be thoroughly inspected. While they do make things easier, I would never treat it as a "set it and forget it". Many people get away with that approach, but others do not.

                        1 Reply Last reply Reply Quote 1
                        • 1 / 1
                        • First post
                          Last post
                        • Root domain change - should we update existing backlinks which include the redirect from the old root domain to the new one?
                          GFD_Chris
                          GFD_Chris
                          0
                          2
                          29

                        • I have a question about the impact of a root domain redirect on site-wide redirects and slugs.
                          Xiano
                          Xiano
                          0
                          2
                          72

                        • Best use of an old domain?
                          abisti2
                          abisti2
                          0
                          5
                          49

                        • Redirect root domain to www
                          JSTRANDELL
                          JSTRANDELL
                          0
                          6
                          424

                        • Is 301 redirecting all old URLS after a new site redesign to the root domain bad for SEO?
                          Vahe.Arabian
                          Vahe.Arabian
                          0
                          12
                          2.6k

                        • I'm redesigning a website which will have a new URL format. What's the best way to redirect all the old URLs to the new ones? Is there an automated, fast way to do this?
                          GregFindley.co.uk
                          GregFindley.co.uk
                          0
                          2
                          303

                        • Redirect from old wordpress site to new php site? Best approach
                          Vahe.Arabian
                          Vahe.Arabian
                          0
                          7
                          844

                        • Is a 302 redirect the correct redirect from a root URL to a detail page?
                          KeriMorgret
                          KeriMorgret
                          0
                          7
                          1.8k

                        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