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

    How to rewrite/redirect a folder name with .htaccess

    Web Design
    6 4 26.3k
    • 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.
    • SheffieldMarketing
      SheffieldMarketing last edited by

      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
      • customerparadigm.com
        customerparadigm.com last edited by

        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 Reply Quote 0
        • brad.s.knutson
          brad.s.knutson last edited by

          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 Reply Quote 1
          • SheffieldMarketing
            SheffieldMarketing @customerparadigm.com last edited by

            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
            • customerparadigm.com
              customerparadigm.com last edited by

              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
              • MickEdwards
                MickEdwards @brad.s.knutson last edited by

                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
                • 1 / 1
                • First post
                  Last post
                • Using Multiple links/names for the same product?
                  rjonesx. 0
                  rjonesx. 0
                  0
                  4
                  119

                • Http://www.domain.com/services/city or http://www.domain.com/city
                  Landforce
                  Landforce
                  1
                  5
                  163

                • Question #2: All of my INTERNAL links in OSE are being indexed from http://www.e.com/default.asp, and all my EXTERNAL links are linked to http://www.e.com/ am I getting a fraction of the link juice because of that?????
                  RobertFisher
                  RobertFisher
                  0
                  2
                  157

                • Redirects (301/302) versus errors (404)
                  Cyrus-Shepard
                  Cyrus-Shepard
                  0
                  6
                  3.1k

                • Given the lastest Google update, should I rewrite my Flash site or try to present an alternative HTML/CSS site?
                  W3designer
                  W3designer
                  0
                  3
                  446

                • Is it OK to 301 Redirect http://homepage.com to http://blog.homepage.com?
                  SimonCullum
                  SimonCullum
                  0
                  4
                  601

                • SEOMoz crawl report shows a duplicate content and duplicate title for these two url's http://freightmonster.com/ and http://freightmonster.com/index.html. How do I fix this?
                  Smith-Digital
                  Smith-Digital
                  1
                  3
                  610

                • Should /dev folder be blocked?
                  BoulderJoe
                  BoulderJoe
                  0
                  3
                  720

                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