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. Hi anyone please help I use this code but now getting 404 error. please help.

    Hi anyone please help I use this code but now getting 404 error. please help.

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

      #index redirect
      RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index.html\ HTTP/
      RewriteRule ^index.html$ http://domain.com/ [R=301,L]
      RewriteCond %{THE_REQUEST} .html
      RewriteRule ^(.*).html$ /$1 [R=301,L]

      hi anyone please help I use this code but now getting 404 error. please help.

      homepage and service.html page is working, but the rest pages like about.html, servicearea.html, and contact.html is not working showing 404 error.

      and also when you type this URL. generalapplianceserice.ca/about.html

      generalapplianceserice.ca/contact.html

      generalapplianceserice.ca/servicearea.html

      it automatically remove the .HTML extension and shows 404 error, the pages name in root directory is same.

      these pages work like generalapplianceservice.ca and generalapplianceservice.ca/services

      why?

      i also remove this code again but still same issue.

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

        Could you tell us what you are trying to archieve in the first place? Your script proberly wont work, because domain.com is'nt replaced with your own domain, second it's code is only valid for HTTP instead of https, so to work with what we have here, try this:

        RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index.html\ HTTP/
        RewriteRule ^index.html$ https://generalapplianceservice.ca/ [R=301,L]
        RewriteCond %{THE_REQUEST} .html
        RewriteRule ^(.*).html$ /$1 [R=301,L]

        roynguyen 1 Reply Last reply Reply Quote 1
        • roynguyen
          roynguyen @Vanderlindemedia last edited by

          hi, thanks for your reply, Jeroen, I was trying to remove the content duplication, that occurred

          when I was crawling my website with the Moz pro tool.

          its showed me two pages, generalapplianceservice.ca, and generalapplianceservice.ca/index.html

          I was just trying to remove the index.html page.

          so I used the above code. and start getting an error of 404, in 3 to 4 pages of the website.   the pages were correct in the root page, the name of pages was also correct.

          the page was this generalapplianceserice.ca/about.html, before the code and after the code, it removed the generalapplianceserice.ca/about

          .HTML extension from the URL and showing a 404 error.

          right now I used Errordocument 404 code in htaccess file. for handling 404 pages.

          also the change the page name. but I need the same page back.

          any help?

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

            Carefull with what your doing. I think you should revert in the first place if your not setting up a 301 moved status. Because of that, you could lose the (indexed) rankings for your index.html page. What you can do is a manual redirect, i.e

            redirect 301 /index.html /

            This moves (including the ranks) the index.html page back to / the root of your domain. You could also setup a canonical URL > https://moz.com/learn/seo/canonicalization

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

              In addition to the advice and tips you have already received here (in general: be super careful with .htaccess / httpd.conf files, and revert to previous versions if you see unexpected behaviour) one additional tip is to consider turning on logging while you debug the problem.

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

                Thank you guys, for your help it helped my problem to slove. I restore my pages back.

                1 Reply Last reply Reply Quote 0
                • 1 / 1
                • First post
                  Last post
                • I'm struggling to understand (and fix) why I'm getting a 404 error. The URL includes this "%5Bnull%20id=43484%5D" but I cannot find that anywhere in the referring URL. Does anyone know why please? Thanks
                  Nichole.wynter2020
                  Nichole.wynter2020
                  0
                  3
                  28

                • OMG!! 1300 404 Errors. HELP ME!!!
                  djlaidler
                  djlaidler
                  1
                  2
                  153

                • Is there a way of changing the Permalink without getting the 404 Error?
                  ThompsonPaul
                  ThompsonPaul
                  0
                  6
                  336

                • Has anyone used a company to help promote their site
                  Debdulal
                  Debdulal
                  0
                  6
                  253

                • I have custom 404 page and getting so much 404 error on Google webmaster, what should i do?
                  NakulGoyal
                  NakulGoyal
                  0
                  3
                  357

                • I always get this error "We have detected that the domain or subfolder does not respond to web requests." I don't know why. PLEASE help
                  JaredMumford
                  JaredMumford
                  0
                  7
                  336

                • Getting a link removed from brand search - please help!
                  palicomp
                  palicomp
                  0
                  3
                  287

                • How to use Author tag - Please help
                  blu42media
                  blu42media
                  0
                  20
                  2.4k

                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