Skip to content
    Moz logo Menu open Menu close
    • Products
      • Moz Pro
      • Moz Pro Home
      • Moz Local
      • Moz Local Home
      • STAT
      • Moz API
      • Moz API Home
      • Compare SEO Products
      • Moz Data
    • Free SEO Tools
      • Domain Analysis
      • Keyword Explorer
      • Link Explorer
      • Competitive Research
      • MozBar
      • More Free SEO Tools
    • Learn SEO
      • Beginner's Guide to SEO
      • SEO Learning Center
      • Moz Academy
      • SEO Q&A
      • Webinars, Whitepapers, & Guides
    • Blog
    • Why Moz
      • Agency Solutions
      • Enterprise Solutions
      • Small Business Solutions
      • Case Studies
      • The Moz Story
      • New Releases
    • Log in
    • Log out
    • Products
      • Moz Pro

        Your all-in-one suite of SEO essentials.

      • Moz Local

        Raise your local SEO visibility with complete local SEO management.

      • STAT

        SERP tracking and analytics for enterprise SEO experts.

      • Moz API

        Power your SEO with our index of over 44 trillion links.

      • Compare SEO Products

        See which Moz SEO solution best meets your business needs.

      • Moz Data

        Power your SEO strategy & AI models with custom data solutions.

      NEW Keyword Suggestions by Topic
      Moz Pro

      NEW Keyword Suggestions by Topic

      Learn more
    • Free SEO Tools
      • Domain Analysis

        Get top competitive SEO metrics like DA, top pages and more.

      • Keyword Explorer

        Find traffic-driving keywords with our 1.25 billion+ keyword index.

      • Link Explorer

        Explore over 40 trillion links for powerful backlink data.

      • Competitive Research

        Uncover valuable insights on your organic search competitors.

      • MozBar

        See top SEO metrics for free as you browse the web.

      • More Free SEO Tools

        Explore all the free SEO tools Moz has to offer.

      NEW Keyword Suggestions by Topic
      Moz Pro

      NEW Keyword Suggestions by Topic

      Learn more
    • Learn SEO
      • Beginner's Guide to SEO

        The #1 most popular introduction to SEO, trusted by millions.

      • SEO Learning Center

        Broaden your knowledge with SEO resources for all skill levels.

      • On-Demand Webinars

        Learn modern SEO best practices from industry experts.

      • How-To Guides

        Step-by-step guides to search success from the authority on SEO.

      • Moz Academy

        Upskill and get certified with on-demand courses & certifications.

      • MozCon

        Save on Early Bird tickets and join us in London or New York City

      Unlock flexible pricing & new endpoints
      Moz API

      Unlock flexible pricing & new endpoints

      Find your plan
    • Blog
    • Why Moz
      • Small Business Solutions

        Uncover insights to make smarter marketing decisions in less time.

      • Agency Solutions

        Earn & keep valuable clients with unparalleled data & insights.

      • Enterprise Solutions

        Gain a competitive edge in the ever-changing world of search.

      • The Moz Story

        Moz was the first & remains the most trusted SEO company.

      • Case Studies

        Explore how Moz drives ROI with a proven track record of success.

      • New Releases

        Get the scoop on the latest and greatest from Moz.

      Surface actionable competitive intel
      New Feature

      Surface actionable competitive intel

      Learn More
    • Log in
      • Moz Pro
      • Moz Local
      • Moz Local Dashboard
      • Moz API
      • Moz API Dashboard
      • Moz Academy
    • Avatar
      • Moz Home
      • Notifications
      • Account & Billing
      • Manage Users
      • Community Profile
      • My Q&A
      • My Videos
      • Log Out

    The Moz Q&A Forum

    • Forum
    • Questions
    • Users
    • Ask the Community

    Welcome to the Q&A Forum

    Browse the forum for helpful insights and fresh discussions about all things SEO.

    1. Home
    2. SEO Tactics
    3. On-Page Optimization
    4. How can I fix multiple 404 errors with Wildcard htaccess redirect

    Moz Q&A is closed.

    After more than 13 years, and tens of thousands of questions, Moz Q&A closed on 12th December 2024. Whilst we’re not completely removing the content - many posts will still be possible to view - we have locked both new posts and new replies. More details here.

    How can I fix multiple 404 errors with Wildcard htaccess redirect

    On-Page Optimization
    3
    12
    5564
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as question
    Log in to reply
    This topic has been deleted. Only users with question management privileges can see it.
    • Taiger
      Taiger Subscriber last edited by

      Hi all I hope that someone can help....

      How can I fix multiple 404 errors with Wildcard htaccess redirect

      The url in question is:

      How can I fix multiple 404 errors with Wildcard htaccess redirect

      http://www.5starweddingdirectory.com/listing/search/Category/luxury_hotels_venues_uk_wedding_venues/exclusive_use_venues/letter/c

      http://www.5starweddingdirectory.com/listing/location/uk-england/bedfordshire-weddings/franklin-park

      http://www.5starweddingdirectory.com/deal/location/uk-england/chorley-weddings/curtis-bay

      etc, going to http://www.5starweddingdirectory.com/business

      the above is just a few examples, google webmaster is showing over  8.000 404 page not found errors.

      Thanks in advance.

      1 Reply Last reply Reply Quote 0
      • Taiger
        Taiger Subscriber 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
        • Christy-Correll
          Christy-Correll Staff last edited by

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

          1 Reply Last reply Reply Quote 0
          • Christy-Correll
            Christy-Correll Staff 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
            • Taiger
              Taiger Subscriber 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
              • 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 Subscriber 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

                    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 Subscriber 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 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 Subscriber 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 last edited by

                            You can fix this issue much easier than trying to sort out redirects in htaccess. You are coming across this issue because your site uses relative URLs rather than absolute.

                            Example:

                            A relative URL isn't tied to a base URL so:

                            /business

                            Absolute would be:

                            www.5starweddingdirectory.com/business

                            Using relative means that when you visit a page your link is relative to that location so if I was on

                            www.5starweddingdirectory.com/business and visited the same llink it would become

                            www.5starweddingdirectory.com/business/business unless redirected.

                            Having to fix this issue in htaccess can get messy for this and it would be much simpler to change your nav links in the template of your site. I checked this was the case in your sites source code to be certain and you definitely use relative URLs.

                            1 Reply Last reply Reply Quote 0
                            • 1 / 1
                            • First post
                              Last post

                            Got a burning SEO question?

                            Subscribe to Moz Pro to gain full access to Q&A, answer questions, and ask your own.


                            Start my free trial


                            Browse Questions

                            Explore more categories

                            • Moz Tools

                              Chat with the community about the Moz tools.

                            • SEO Tactics

                              Discuss the SEO process with fellow marketers

                            • Community

                              Discuss industry events, jobs, and news!

                            • Digital Marketing

                              Chat about tactics outside of SEO

                            • Research & Trends

                              Dive into research and trends in the search industry.

                            • Support

                              Connect on product support and feature requests.

                            • See all categories

                            Related Questions

                            • Veevlimike

                              Issues with Multiple H1 tags on homepage?

                              Hi folks, My homepage has 3 identical H1 tags due to the fact that I have had to create individual hero images (with headings) for desktop, tablet and mobile. I couldn't get my theme to display the layout in exactly the way I wanted on each device without doing a specific hero image and tag for each device type. Does this have a major impact on my SEO? Thanks,
                              Mike.

                              On-Page Optimization | | Veevlimike
                              0
                            • Unbranded_Lee

                              301 Redirect or landing page

                              Hi everyone. I'm currently doing some SEO for a client, at the moment he has some landing pages which are categorised, but the category is set as a 302 redirect. I have a dilemma whether to 301 redirect to the landing page or make a page for each category. The link structure is as follows - http://examplesite.co.uk/products/fire/company-1/product/ so currently this is set as a 302 redirect - http://examplesite.co.uk/products/fire/company-1/ Do I make this page a category page and link the page to the children with some on-page optimisation or 301 redirect it?

                              On-Page Optimization | | Unbranded_Lee
                              0
                            • estebanseo

                              Using keywords in my URL: Doing a redirect to /keyword

                              My website in "On Page Grade" received an A.Anyway, I only have 1 thing to optimize:_"Use Keywords in your URL__Using your targeted keywords in the URL string adds relevancy to your page for search engine rankings, assists potential visitors identify the topic of your page from the URL, and provides SEO value when used as the anchor text of referring links."_My website is ranking in top10 for a super high competitive keyword and all my others competitors have the keyword on their domain, but not for my URL.Since I can't change my domain for fixing this suggestion, I would like to know what do you think about doing a 301 redirect from / to mydomainname.com/keyword/So the index of my website would be the /keyword.I don't know if this can make a damage to my SERP for the big change ir it would be a great choice.

                              On-Page Optimization | | estebanseo
                              0
                            • quiltedkoala

                              How do I fix duplicate page issue on Shopify with duplicate products because of collections.

                              I'm working with a new client with a site built on Shopify. Most of their products appear in four collections. This is creating a duplicate content challenge for us. Can anyone suggest specific code to add to resolve this problem. I'm also interested in other ideas solutions, such as "don't use collections" if that's the best approach. I appreciate your insights. Thank you!

                              On-Page Optimization | | quiltedkoala
                              0
                            • jcgoodrich

                              What is the best way to execute a geo redirect?

                              Based on what I've read, it seems like everyone agrees an IP-based, server side redirect is fine for SEO if you have content that is "geo" in nature. What I don't understand is how to actually do this. It seems like after a bit of research there are 3 options: You can do a 301 which it seems like most sites do, but that basically means if google crawls you in different US areas (which it may or may not) it essentially thinks you have multiple homepages. Does google only crawl from SF-based IPs? 302 passes no juice, so probably don't want to do that. Yelp does a 303 redirect, which it seems like nobody else does, but Yelp is obviously very SEO-savvy. Is this perhaps a better way that solves for the above issues? Thoughts on what is best approach here?

                              On-Page Optimization | | jcgoodrich
                              0
                            • KLLC

                              Review my website and guide me what can do for top ranking.

                              Hi Guys, I really need your advice for my website (bmgapt dot com). I'm loosing ranking on (Buffalo Apartments) keyword. Two months ago my ranking number is 3 but now loosing to 15 number. What can I do for get again top ranking. Thanks in advance. John Smith

                              On-Page Optimization | | KLLC
                              0
                            • TBSEO

                              Image titles and alt tags for multiple images

                              I'm hoping some of you may be able to help me understand the best way to optimize my image titles and alt tags for a specific situation. I'm working on an interior design website and they have hundreds of pictures. each of their projects has about 10 pictures. Is it best for me to us the key phrase in each title and tag? or is that to repetitive? here is what I mean: A project called "urban interior design" all images are of urban interior design, just different angles and features, so my initial idea is to just have each image title like this: Title: "urban interior design dinning area" Alt: "urban interior design dinning area view" Title: "urban interior design living room" Alt:"urban interior design living room couch view" Is this the best way or will it actually hurt my ranking with too much exact keyword use? Thanks for your help!

                              On-Page Optimization | | TBSEO
                              0
                            • CMC-SD

                              How much juice do you lose in a 301 redirect?

                              Our site has a number of, shall we say, unoptimized URLs. I would like to change the URLs to be more relevant; if a page is about red widgets, the URL should be www.domain.com/red-widgets.html, right? I'm getting resistance on this, however, based on the belief that you lose something significant when you 301 an old URL to a new one. Now, I know that if you have a long chain of redirects, the spiders will stop following at some point, and that is a huge problem. That wouldn't apply if there's only one step in the chain, however. I've also heard that you lose some link juice in a 301, but I'm unsure how serious that problem actually is. Is it small enough that we'd win out in the long run with better-optimized URLs?

                              On-Page Optimization | | CMC-SD
                              0

                            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
                            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 - 2025 SEOMoz, Inc., a Ziff Davis company. All rights reserved. Moz is a registered trademark of SEOMoz, Inc.
                            • Accessibility
                            • Terms of Use
                            • Privacy

                            Looks like your connection to Moz was lost, please wait while we try to reconnect.