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
    • MozCon
    • Webinars, Whitepapers, & Guides
  • Blog
  • Why Moz
    • Digital Marketers
    • Agency Solutions
    • Enterprise Solutions
    • Small Business Solutions
    • 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.

    Let your business shine with Listings AI
    Moz Local

    Let your business shine with Listings AI

    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
    • Digital Marketers

      Simplify SEO tasks to save time and grow your traffic.

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

    • 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

              • paul-bold

                Should I Redirect Pagination?

                Working on a redirect map for a client moving platforms and they have all of their category pagination indexed - no canonical link and no rel next/prev's on any of them. Should I redirect the pagination pages to the main category page on the new platform? Or Should I allow the pagination to de-index itself type of thing? Thoughts and experience?

                Web Design | May 30, 2016, 4:02 AM | paul-bold
                0
              • Zuken

                Block parent folder in robot.txt, but not children

                Example: I want to block this URL (which shows up in Webmaster Tools as an error): http://www.siteurl.com/news/events-calendar/usa But not this: http://www.siteurl.com/news/events-calendar/usa/event-name

                Web Design | Mar 8, 2016, 8:26 AM | Zuken
                0
              • jwanner

                How long should an old site redirecting to a new site remain activated on a server?

                Once I switch a site to a new domain (with links to corresponding/relative pages), will I have to keep the old site live forever for those links to work, or how long should I wait before I inactivate the old site on our server?

                Web Design | Jun 28, 2015, 12:58 PM | jwanner
                0
              • KevinBloom

                Multiple websites for different service areas/business functions?

                I'm wondering what the implications are for having multiple domains for different service areas of a company? I realize having multiple domains for one company can be troublesome because of the possibility of duplicate content, keyword cannibalization, and linkbuilding to multiple domains. But when the domains are for very different service offerings/unique business functions that each serve  their own purpose (and have  different positionings), is there a downside to having more than one domain? Any thoughts would be appreciated!

                Web Design | Jan 14, 2015, 6:45 PM | KevinBloom
                0
              • DRSearchEngOpt

                Best way to indicate multiple Lang/Locales for a site in the sitemap

                So here is a question that may be obvious but wondering if there is some nuance here that I may be missing. Question:  Consider an ecommerce site that has multiple sites around the world but are all variations of the same thing just in different languages.  Now lets say some of these exist on just a normal .com page while others exist on different ccTLD's.  When you build out the XML Sitemap for these sites, especially the ones on the other ccTLD's, we want to ensure that using <loc>http://www.example.co.uk/en_GB/"</loc> <xhtml:link<br>rel="alternate"
                hreflang="en-AU"
                href="http://www.example.com.AU/en_AU/"
                />
                <xhtml:link<br>rel="alternate"
                hreflang="en-NZ"
                href="http://www.example.co.NZ/en_NZ/"
                /> Would be the correct way of doing this.  I know I have to change this for each different ccTLD but it just looks weird when you start putting about 10-15 different language locale variations as alternate links.  I guess I am just looking for a bit of re-affirmation I am doing this right.</xhtml:link<br></xhtml:link<br> Thanks!

                Web Design | Mar 24, 2014, 6:03 PM | DRSearchEngOpt
                0
              • NoisyLittleMonkey

                Is it bad to have /index.php at the end of a uri?

                Is it bad for SEO if traffic is directed to "http://www.example.com/someuri/index.php" instead of "http://www.example.com/someuri/" and would it be works setting up a redirect rule at htaccess level?

                Web Design | Oct 4, 2013, 10:54 AM | NoisyLittleMonkey
                1
              • RankSurge

                Does anyone think the <figcaption>attribute from HTML5 will have any influence for image search?</figcaption>

                There is a <figure>element that is supposed to provide better descriptions of image on the web in HTML5 - do you think that will replace the importance of the "Alt" tag? Link to figcaption description </figure>

                Web Design | Feb 15, 2012, 4:02 PM | RankSurge
                2
              • 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

              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.