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. On-Page / Site Optimization
    4. How can I fix multiple 404 errors with Wildcard htaccess redirect

    How can I fix multiple 404 errors with Wildcard htaccess redirect

    On-Page / Site Optimization
    12 3 4.3k
    • 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.
    • Taiger
      Taiger last edited by

      Hi Matt, and thank you for your response.

      Not sure if i understand the solution to this problem though. The http://www.5starweddingdirectory.com/listing/......./ are from old legacy urls, and we have many. I am not sure why google webmaster is still picking up these old urls. but having 8k old not found urls is a worry.

      Regards Tai

      Matt-Williamson 1 Reply Last reply Reply Quote 0
      • Matt-Williamson
        Matt-Williamson @Taiger last edited by

        Hi Tai,

        I had a look at your site homepage and from your examples I could see you have relative urls which can cause 404 errors and as you mentioned 8000 I thought this could be part of your problems - no domains in your main navigation links so /business rather than www.yourdomain.com/business in coding - so no base URL can cause this. I took one of your links you mentioned to check if your hrefs were relative.

        Putting what I mentioned aside for a second do you just want anything that is /listing and /deal redirecting to /business?

        Have you tried this for the listing example and repeat for the others such as /deal/:

        RedirectMatch 301 ^/listing/.*$ http://www.5starweddingdirectory.com/business

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

          Hi Matt, thanks again.

          Yes we are trying to redirect old urls to the relevant pages.

          As we have so many old urls from old cms system which had different url structures, to do a wildcard to catch all 404s would be great. (wordpress plugin wp redirection achieves this http://wordpress.org/plugins/redirection/)

          RedirectMatch 301 ^/listing/.*$ http://www.5starweddingdirectory.com/business

          But it did not redirect

          http://www.5starweddingdirectory.com/listing/location/uk-england/essex-weddings

          Thanks for your time on this.

          Regards Tai

          Matt-Williamson 1 Reply Last reply Reply Quote 0
          • Matt-Williamson
            Matt-Williamson @Taiger last edited by

            Hi Tai,

            I understand what you are saying in regards to making it easier with all the different URLs, however you will need to specify some start point in terms of being one level down from the domain root else you are effectively placing a wildcard on the whole domain, which wouldn't work when you are still working on this domain. So you need to try to identify the few main category URLs such as /listing and so on in order to create a rule.

            Did the redirect I give you work for all URLs apart from the one listed? It should have worked for that.

            An alternative you can try is:

            RewriteEngine On
            RewriteRule ^listing/(.*)$ http://www.5starweddingdirectory.com/business/ [R=301,L]

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

              Hi Matt,

              RewriteEngine On
              RewriteRule ^listing/(.*)$ http://www.5starweddingdirectory.com/business/ [R=301,L]

              Did not work,

              other urls flagged up in Google WM are/deal/ new: /deals/

              http://www.5starweddingdirectory.com/deal/location/uk-england/buckinghamshire-weddings/newport-beach

              http://www.5starweddingdirectory.com/deals/

              thanks Matt

              Matt-Williamson 1 Reply Last reply Reply Quote 0
              • Matt-Williamson
                Matt-Williamson @Taiger last edited by

                Using the redirectmatch directive to redirect the entire deal directory to deals should definitely work for your situation. You then just repeat for each - so for deals:

                RedirectMatch 301 /deal/(.*) /deals/$1

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

                  Hi Matt, sorry for the delay in getting back.

                  Just working on your suggestions, I will let you know if it works

                  T

                  1 Reply Last reply Reply Quote 0
                  • Christy-Correll
                    Christy-Correll last edited by

                    Hi Tai! Any update on this issue? Please let us know so we can help! Thanks.

                    Christy

                    1 Reply Last reply Reply Quote 0
                    • Christy-Correll
                      Christy-Correll last edited by

                      Hi Tai, were you able to implement Matt's suggestions?

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

                        Hi Denverish, thanks for your reply, been months since i looked at this problem. It has returned so trying to sort it out. the redirects mentioned did not work. so any suggestions.

                        The CMS allows for 301 redirects via a form; place old url at the top of the form and the new url at the bottom and save,

                        But as I am trying to create a wildcard 301 redirect, i am not sure what code to place in these fields..see pic

                        tai

                        MgrqdVB.png

                        1 Reply Last reply Reply Quote 0
                        • 1 / 1
                        • First post
                          Last post
                        • My site auto redirects http to https. This is causing redirect chains. What can I do?
                          WebQuest
                          WebQuest
                          0
                          2
                          130

                        • Weird 404 Error URL's - Where to redirect?
                          MrWhippy
                          MrWhippy
                          0
                          6
                          63

                        • Internal 404 Error
                          MattAntonino
                          MattAntonino
                          0
                          5
                          109

                        • .htaccess redirect chains
                          ztalk112
                          ztalk112
                          0
                          4
                          458

                        • To redirect or not to redirect...That is the question
                          EGOL
                          EGOL
                          0
                          3
                          189

                        • 404 error only png and bmp
                          Chris.Menke
                          Chris.Menke
                          0
                          4
                          159

                        • Redoing a site - 404 redirect or 301 redirect
                          danatanseo
                          danatanseo
                          0
                          3
                          536

                        • After Deletion of URL - Which is bettar 301 redirect or Error 404 Message.
                          NakulGoyal
                          NakulGoyal
                          0
                          6
                          394

                        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