undefined
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.

    • SEO Q&A

      Insights & discussions from an SEO community of 500,000+.

    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. Technical SEO
  4. 301 Redirect for multiple links

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.

301 Redirect for multiple links

Technical SEO
2
6
2.8k
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.
  • shawnbeaird
    shawnbeaird last edited by Jan 7, 2017, 12:02 AM

    I just relaunched my website and changed a permalink structure for several pages where only a subdirectory name changed.

    What 301 Redirect code do I use to redirect the following? I have dozens of these where I need to change just the directory name from "urban-living" to "urban", and want it to catch the following all in one redirect command.

    Here is an example of the structure that needs to change.

    Old 
    domain.com/urban-living (single page w/ content)
    domain.com/urban-living/tempe (single page w/ content)
    domain.com/urban-living/tempe/the-vale (single page w/ content)

    New 
    domain.com/urban 
    domain.com/urban/tempe 
    domain.com/urban/tempe/the-vale

    1 Reply Last reply Reply Quote 0
    • FrankViolette
      FrankViolette @shawnbeaird last edited by Jan 7, 2017, 3:01 PM Jan 7, 2017, 3:01 PM

      Glad it works!

      1 Reply Last reply Reply Quote 1
      • shawnbeaird
        shawnbeaird last edited by Jan 7, 2017, 3:00 PM Jan 7, 2017, 3:00 PM

        Got it. That works. I was using Yoast Premium Redirect tools.

        RewriteRule ^(.)urban-living(.)$ yoursite.com/$1urban$2 [R=301,L]   the "yoursite.com/" wasn't necessary.

        This did the trick. RewriteRule ^(.)urban-living(.)$ /$1urban$2 [R=301,L]

        Thanks!

        FrankViolette 1 Reply Last reply Jan 7, 2017, 3:01 PM Reply Quote 2
        • FrankViolette
          FrankViolette @shawnbeaird last edited by Jan 7, 2017, 2:59 PM Jan 7, 2017, 1:33 PM

          Yeah, that would be a lot of lines to add manuall., I would try the htaccess Rewrite function.

          <ifmodule mod_rewrite.c="">RewriteEngine On
          RewriteBase /

          RewriteRule ^(.)urban-living(.)$ yoursite.com/$1urban$2 [R=301,L]</ifmodule>

          RewriteCond %{REQUEST_FILENAME} !-f
          RewriteCond %{REQUEST_FILENAME} !-d

          RewriteRule ^(.*)$ index.php?/$1 [L]

          RewriteCond %{HTTP_HOST} !^www.yoursite.com$ [NC]
          RewriteRule ^(.*)$ yoursite.com//$1 [L,R=301]

          I'm not an htaccess expert, so I'm not 100% sure that it will work, if not you can check out this stack overflow thread for an explanation of the code used above.

          1 Reply Last reply Reply Quote 2
          • shawnbeaird
            shawnbeaird last edited by Jan 7, 2017, 1:21 PM Jan 7, 2017, 1:21 PM

            I have more than a dozen... dozenS as in plural.  There are 80 pages with this and want to use a single command to capture all of them, not do them individually.

            Is there a way to to that?

            FrankViolette 1 Reply Last reply Jan 7, 2017, 1:33 PM Reply Quote 0
            • FrankViolette
              FrankViolette last edited by Jan 7, 2017, 3:48 AM Jan 7, 2017, 3:48 AM

              Since you only have a dozen of URLs you could just do a simple 301 redirect in your .htaccess file or you can get a little more technical and do a RewriteRule that would 301 "urban-living" to "urban'

              .htaccess 301 Redirect

              Redirect 301/urban-living /urban 
              Redirect 301/urban-living/tempe /urban/tempe
              Redirect 301/urban-living/tempe/the-vale /urban/tempe/the-vale

              Hope this helps, if not, let me know if you have any questions!

              1 Reply Last reply Reply Quote 0
              • 1 / 1
              1 out of 6
              • First post
                1/6
                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

              • Corbec888

                Is link equity passed through redirect chains?

                Hi there, When redirects are passed through multiple stages e.g. https://www.google.com 301 to http://www.bing.com 301 to http://www.yahoo.com Does http://www.yahoo.com still retain all link equity from the original referring domain, and is there a limit to the redirect chain before Google starts to not pass through link equity? Cheers

                Technical SEO | Jun 9, 2018, 3:24 AM | Corbec888
                1
              • DanielKiely6

                Hreflang tags with link to redirect loop

                Hi guys, I'm having a bit of an issue on a client site that I'm hoping someone can help me with. Basically, the client has two domains, one serving users in the Republic of Ireland (http://www.americanholidays.com), showing Euro prices, and the other serving users in Northern Ireland (http://www.americanholidays.com/gb_en/) showing £ prices. The issue I'm having is that the URL for the Northern Ireland page has a 302 on it and goes through another 2/3 301 redirects until it resolves as http://www.americanholidays.com, however it does then show the £ prices. You can see the redirect chain here: http://tools.seobook.com/server-header-checker/?page=single&url=http%3A%2F%2Fwww.americanholidays.com%2Fgb_en%2F&useragent=1&typeProtocol=11 The homepage is using the Hreflang tag, and pointing search engines to serve the http://www.americanholidays.com/gb_en/ page to users using EN-GB as their language. The page is also using a self-referencing canonical, which I believe may negate the whole Hreflang tag anyway? My main question is - is the fact that the Hreflang for the gb_en page is pointing to a chain of redirects negatively affecting it? (I understand too many redirects are never good). Also, is the canonical negating the Hreflang? Any help/info would be great as I just can't get my head around it! Thanks guys Daniel

                Technical SEO | Apr 13, 2016, 8:44 AM | DanielKiely6
                0
              • shawn81

                Should 301-ed links be removed from sitemap?

                In an effort to do some housekeeping on our site we are wanting to change the URL format for a couple thousand links on our site. Those links will all been 301 redirected to corresponding links in the new URL format. For example, old URL format: /tag/flowers as well as search/flowerswill be 301-ed to, new URL format: /content/flowers**Question:**Since the old links also exist in our sitemap, should we add the new links to our sitemap in addition to the old links, or replace the old links with new ones in our sitemap? Just want to make sure we don’t lose the ranking we currently have for the old links.Any help would be appreciated. Thanks!

                Technical SEO | Jan 6, 2014, 4:25 PM | shawn81
                1
              • Gotmoxie

                How do I fix a 301 Redirect Loop?

                Saturday I waas doing some correcting of some duplicate titles, including nofollowing tags, etc. (my main problem was duplicate titles due to tags and categories being indexed). Now this morning I see that one of my pages refuses to load, citing a 301 redirect loop. http://www.incredibleinfant.com/feeding/switching-baby-formula/ Originally, the page was posted under the wrong category. http://www.incredibleinfant.com/uncategorized/switching-baby-formula I resaved it under the correct category (feeding) and now it won't load. Can someone help me figure out how to correct this mess? Thanks so much Heather

                Technical SEO | Dec 12, 2012, 1:25 PM | Gotmoxie
                0
              • TrevorMcKendrick

                301 Redirect with an Exact Domain name Match

                My Client had a site that ranked for a pretty competitive two word phrase, but for a variety of reasons had to transfer the site to a different domain name (with none of the previous keywords). We've 301'd everything just fine to the new site, but our traffic for that two word phrase, as well as related long tail traffic, is beginning to drop. Could the drop be related to something that we didn't do well in the transfer? Or is it due to the new domain name now not being an exact match? Sitenote question: Our Google Analytics is still set up for the former domain name and shows data just fine. Is there any reason to switch GA to the new domain? What are the pros/cons? Much thanks in advance!

                Technical SEO | Dec 7, 2011, 7:16 AM | TrevorMcKendrick
                0
              • upick-162391

                Trailing Slashes In Url use Canonical Url or 301 Redirect?

                I was thinking of using 301 redirects for trailing slahes to no trailing slashes for my urls. EG: www.url.com/page1/ 301 redirect to www.url.com/page1 Already got a redirect for non-www to www already. Just wondering in my case would it be best to continue using htacces for the trailing slash redirect or just go with Canonical URLs?

                Technical SEO | Nov 27, 2011, 12:19 PM | upick-162391
                0
              • steffen_

                Double 301 redirect

                Hi together, due to some technical reasons I have redirect (301) an existing link two times. Example: www.mydomain.com/root/site.html > 301 > www.mydomain.com/site.html > 301 www.mydomain.com/site_new.html Is there anybody how has got some experience like doing a double redirect? What about link juice? Best regards Steffen

                Technical SEO | Sep 18, 2011, 2:39 PM | steffen_
                0
              • craigycraig

                301 Redirect "wildcard" question

                I have been looking at the SEOmoz redirect guide for some advice but I can't seem to find the answer : http://www.seomoz.org/learn-seo/redirection I have lots of URLs from a previous version of a site that look like the following: sitename.com/-c-25.html?sort=2d&page=1 sitename.com/-c-25.html?sort=3a&page=1 etc etc. I want to write a redirect so whenever a URL with the terms "-c-25.html" is requested it redirects to a specified page, regardless of what comes after the question mark. These URLs were created by our previous ecommerce software. The 'c' is for category, and each page of the cateogry created a different URL. I want to do these so I can rediect all of these URLs to the appropraite new cateogry page in a single redirect. Thanks for any help.

                Technical SEO | Dec 23, 2012, 6:28 PM | craigycraig
                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.