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. Digital Marketing
  3. Web Design
  4. How to rewrite/redirect a folder name with .htaccess

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 to rewrite/redirect a folder name with .htaccess

Web Design
4
6
28.5k
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.
  • SheffieldMarketing
    SheffieldMarketing last edited by Dec 13, 2013, 5:35 PM

    I have a folder in my site that I want to rename. I don’t want to just rewrite the URL and keep my old folder name, I want to change the folder name and then do whatever is necessary with .hataccess to not lose search engine rankings. The folder name I want to change has a space in it and also is misspelled (whoops x2)

    Example.

    Mysite.com/old foldr/page.html

    Mysite.com/newfolder/page.html

    How would I go about doing this with .htaccess?  Do I just switch the folder name on my server and then set up a redirect, or do I do a rewrite?  Sorry now familiar with the terms or .htacces.

    Thanks all

    1 Reply Last reply Reply Quote 0
    • MickEdwards
      MickEdwards @brad.s.knutson last edited by Dec 14, 2013, 9:34 AM Dec 14, 2013, 9:34 AM

      You might possibly have to detail the white-space explicitly with \s

      RewriteEngine On
      RewriteRule ^old\sfoldr/(.*) /newfolder/$1 [R=301,NC,L]

      1 Reply Last reply Reply Quote 0
      • customerparadigm.com
        customerparadigm.com last edited by Dec 13, 2013, 6:10 PM Dec 13, 2013, 6:10 PM

        Yes, Bradley's method will allow you to redirect everything in the folder.  I thought you were just needing to re-index one file. 🙂

        1 Reply Last reply Reply Quote 0
        • SheffieldMarketing
          SheffieldMarketing @customerparadigm.com last edited by Dec 13, 2013, 6:08 PM Dec 13, 2013, 6:08 PM

          Ok thank you! Unfortunately there are LOTS of .html files within this folder, is there a way to just switch the folder name and not each individual file?

          1 Reply Last reply Reply Quote 0
          • brad.s.knutson
            brad.s.knutson last edited by Dec 13, 2013, 6:08 PM Dec 13, 2013, 6:06 PM

            To 301 redirect all files in the direct to the new directory in .htaccess, try this:

            RewriteEngine On
            RewriteRule ^old\ foldr/(.*) /newfolder/$1 [R=301,NC,L]

            This should redirect all HTML pages, images, you name it.  It should also account for the space too.

            You'll want to move all your files to the new folder location so when the redirect happens your end user doesn't receive a 404 error.

            MickEdwards 1 Reply Last reply Dec 14, 2013, 9:34 AM Reply Quote 1
            • customerparadigm.com
              customerparadigm.com last edited by Dec 13, 2013, 6:01 PM Dec 13, 2013, 6:01 PM

              Yes, you will want to create a 301 redirect from the older location to the newer location.

              Steps to take:

              1. Change the folder on your server from /old foldr/ --> /newfolder/

              2. Add this line in your .htaccess file:

              redirect 301 /old%20foldr/page.html http://www.mysite.com/newfolder/page.html

              **3. Make sure this is working properly. ** I like to use this 301 redirect checker tool:

              http://httpstatus.io/

              SheffieldMarketing 1 Reply Last reply Dec 13, 2013, 6:08 PM 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

              • NachoRetta

                Spanish website indexed in English, redirect to spanish or english version if i do a new website design?

                Hi MOZ users, i have this problem. We have a website in Spanish Language but Google crawls it on English (it is not important the reasons). We re made the entire website and now we are planning the move. The new website will have different language versions, english, spanish and portuguese. Somebody tells me that we have to redirect the old urls (crawled on english) to the new english versions, not to the spanish (the real language of the firsts). Example: URL1 Language: Spanish - Crawled on English --> redirect to Language English version. the other option will be redirect to the spanish new version, which the visitor is waiting to find. URL1 Language: Spanish - Crawled on English --> redirect to Language Spanish version. What do you think? Which is the better option?

                Web Design | Nov 25, 2015, 2:03 PM | NachoRetta
                0
              • Discountvc

                301 Redirect all pictures when moving to a new site?

                We have 30,000 pictures on our site. Moz will return 404's on some occasionally, but Google seems to ignore those. Should I 301 redirect all those images when we move to a new site lay-out? Appreciate your views!

                Web Design | May 14, 2015, 12:44 PM | Discountvc
                0
              • JaanMSonberg

                SEO strategy for UK / US websites

                Hi, We currently have a UK-focused site on www.palmatin.com ; We're now targeting the North American market as well, but the contents of the site need to be different from UK. One option was to create another domain for the NA market but I assume it would be easier to rank with palmatin.com though. What would you suggest to do, if a company is targeting two different countries in the same language? thanks, jaan

                Web Design | Nov 12, 2014, 7:48 AM | JaanMSonberg
                0
              • KempRugeLawGroup

                Privacy Policy: index it/? And where to place it?

                Hi Everyone, Two questions, first: should you allow google to index your privacy policy? Second: for a service based site (not e-commerce, not selling anything) should you put the policy in the footer so it's site wide or just on the "contact us" form page? Best, Ruben

                Web Design | Nov 12, 2014, 6:35 AM | KempRugeLawGroup
                0
              • BallyhooLtd

                Does Google follow links inside a <noscript>tag?</noscript>

                I'm looking at making an embedable calculator and asking users to embed it to their website. I had the idea of using javascript to include the calculator which would also conatain a text link back to my site in order to gain some back links. If it's possible Google won't see the link (as they may not execute the javascript), is it safe to place the link in the <noscript>tag? If so, Will it be indexed and will Page Rank be passed?</span></p> <p>Thanks in advance for your answers. </p> <p>Anthony</p> <p><span style="color: #5e5e5e;"><br /></span></p></noscript>

                Web Design | Sep 28, 2012, 4:14 PM | BallyhooLtd
                0
              • WilliamBay

                Display a message after 301 redirect.

                I know this one is a little more technical than pure SEO, but it somewhat ties in. I'm redirecting 2 sites to one. The companies have combined, and I've imported all their content that has been created, and the url mapping is set up correctly. So it currently is set up like this: A.com --> C.com
                A.com/blogpost-1 --> C.com/blogpost-1 B.com --> C.com B.com/blogpost-20 --> C.com/blogpost-20 What i would like is some method a redirect when landing at C.com or C.com/blogpost-XX. And in turn display a message in a DIV so I can style it. And yes, I have nothing better to do on a Friday night 🙂

                Web Design | Feb 11, 2012, 8:42 PM | WilliamBay
                0
              • SeMeAntoja

                I have a button that repeats it self many times on same page, what can i do so button name does not affect my SEO?

                I have a shopping car button named "Add to car" but it repeats on many pages on my website, is this affecting my seo? If yes.. What should i do so it does not affect? Should button appear on hover? Thanks

                Web Design | Nov 5, 2011, 12:50 AM | SeMeAntoja
                0
              • jmansd

                Is it necessary to redirect every Error page (404 or 500) found?

                If I have Hundreds of pages with 404 and 500 erros should set up 301 redirects for all of them?  Some of the pages have external links, some don't.

                Web Design | Jun 13, 2011, 7:05 PM | jmansd
                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.