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. Changing permalinks in new wordpress website using regex in 301s?

    Changing permalinks in new wordpress website using regex in 301s?

    Technical SEO Issues
    5 3 70
    • 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.
    • musthavemarketing
      musthavemarketing last edited by

      Hi there

      I am working on a website and we would like to change the permalinks from product-category (replacing with Shop) and product to buy.   Currently there are nearly 400 products and multiple categories.

      Although the website has just been indexed wondering if we need to do 301's? if we did would like to use regex to manage

      so redirect would be as example:  mydomain.com/sub-domain/product-category/ redirecting to to mydomain.com/sub-domain/shop/ (I know you do not need to put in the domain but as an example) - could anyone give me the regex for this?

      Same for products: mydomain.com/sub-domain/product/sample-product redirect to mydomain.com/sub-domain/buy/sample-product

      thanks in anticipation

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

        Hi Allie,

        Sounds like you've got two questions:

        First, you'll need to use 301s if you have any inbound links to the pages that you're replacing.

        Second, you can't use Regex in HTML. Do you have a CMS that can help you build the 301s?

        Best,

        Kristina

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

          Hello Allie,

          Here is the basic regex redirect code to place in your htaccess file.

          RedirectMatch 301 /sub-folder/product-category/(.) /sub-folder/shop/$1
          RedirectMatch 301 /sub-folder/product/(.
          ) /sub-folder/buy/$1

          Hope this helps. You can also find more information on redirecting old pages using regex from WPEngine here.

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

            Thanks so much for your responses. Will try that now

            Chris_Hickman 1 Reply Last reply Reply Quote 0
            • Chris_Hickman
              Chris_Hickman @musthavemarketing last edited by

              You're welcome. Hope it worked out for you. You can mark this as answered if the problem is solved.

              1 Reply Last reply Reply Quote 0
              • 1 / 1
              • First post
                Last post
              • Merge 2 websites into one, using a non-existing, new domain.
                jarydcat1
                jarydcat1
                0
                4
                96

              • Hi, we are wanting to test a new version of one particular page on our website. What's the best way to run a test for a week without harming rankings. Do we use a 302 redirect or direct 100% of traffic using a tool like Optimizely?
                WebElaine
                WebElaine
                0
                2
                33

              • How to change URL for this website
                Kizinko
                Kizinko
                0
                4
                93

              • As a wholesale website can our independent retailer's website use (copy) our content?
                ewanTHH
                ewanTHH
                0
                5
                514

              • 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

              • Other Websites Crawling my Site using WordPress/3.1 bot?
                AlanMosley
                AlanMosley
                0
                4
                660

              • Our Development team is planning to make our website nearly 100% AJAX and JavaScript. My concern is crawlability or lack thereof. Their contention is that Google can read the pages using the new #! URL string. What do you recommend?
                john4math
                john4math
                0
                2
                651

              • Starting a new product, should we use new domain or subdomain
                KeriMorgret
                KeriMorgret
                0
                4
                1.3k

              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