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

    301 Redirect for multiple links

    Technical SEO Issues
    6 2 1.7k
    • 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.
    • shawnbeaird
      shawnbeaird last edited by

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

        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
        • shawnbeaird
          shawnbeaird last edited by

          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 Reply Quote 0
          • FrankViolette
            FrankViolette @shawnbeaird last edited by

            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

              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 Reply Quote 2
              • FrankViolette
                FrankViolette @shawnbeaird last edited by

                Glad it works!

                1 Reply Last reply Reply Quote 1
                • 1 / 1
                • First post
                  Last post
                • Removing Multiple 301 Redirects
                  GastonRiera
                  GastonRiera
                  0
                  2
                  815

                • Do you still loose 15% of value of inbound links when you redirect your site from http to https (so all inbound links to http are being redirected to https version)?
                  LoganRay
                  LoganRay
                  0
                  5
                  74

                • Updating inbound links vs. 301 redirecting the page they link to
                  AlanMosley
                  AlanMosley
                  0
                  5
                  1.2k

                • Should I consolidate multiple domains to a single site with 301 redirects?
                  dsmdesign
                  dsmdesign
                  0
                  3
                  601

                • 301 Redirect & Linking Root Domain Count
                  iAnalyst.com
                  iAnalyst.com
                  0
                  2
                  466

                • 301 Redirect Domain or 301 Redirect Domain + Interior Pages
                  Room214
                  Room214
                  0
                  7
                  1.1k

                • Will 301 redirecting a site multiple times still preserve the original site value?
                  JoeAmadon
                  JoeAmadon
                  0
                  2
                  588

                • During a site platform transition, should we 301 redirect all URLs or only those with inbound links?
                  RyanKent
                  RyanKent
                  0
                  3
                  775

                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