How to rewrite/redirect a folder name with .htaccess
-
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
-
You might possibly have to detail the white-space explicitly with \s
RewriteEngine On
RewriteRule ^old\sfoldr/(.*) /newfolder/$1 [R=301,NC,L] -
Yes, Bradley's method will allow you to redirect everything in the folder. I thought you were just needing to re-index one file.
-
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?
-
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.
-
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:
Got a burning SEO question?
Subscribe to Moz Pro to gain full access to Q&A, answer questions, and ask your own.
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.
Related Questions
-
Incorporating Spanish Page/Site
We bought an exact match domain (in Spanish) to incorporate with regular website for a particular keyword. This is our first attempt at this, and while we do have Spanish speaking staff that will translate/create a nice, quality page, we're not going to redo everything in Spanish page. Any advice on how to implement this? Do I need to create a whole other website in Spanish? Will that be duplicate content if I do? Can I just set it up to show the first page in Spanish, but if they click on anything else it redirects to our site? I'm pretty clueless on this, so if anything I've suggested is off-the-wall or a violation, I'm really just spit-balling, trying to figure out how to implement this. Thanks, Ruben
Web Design | | KempRugeLawGroup0 -
Does anyone know how to find functions/codes/etc in WordPress?
Right now, I'm working on solving a relatively easy WP issue (easy, because someone told me what to do. Thanks iNetSeo). I have to replace: <span class="post_date"></span class="post_date"> and replace it with <span class="post_date date="" updated"=""></span class="post_date> But, I can't find the "_<span class="post_date">"</span class="post_date">_For a number of my WP problems, the hardest part is just located the code/function/markup I need to replace. Does anyone know where this might usually be stored on a website? Also, does anyone know if there's any tool that would allowed to just put "various function" in a search box, and wordpress take you to where it was on the backend of your site, so you could edit it? I included a screenshot of our editors, but I already opened them all, pasted the code in Ctrl-F to no avail, but maybe I missed something. Thanks for helping with my frustrating scavenger hunt! Ruben ASTPPfA
Web Design | | KempRugeLawGroup0 -
Nesting <a>tag for rel="nofollow"</a>
I just wanted to quickly run this past someone. I have some footer links I want set to nofollow: <map <span="" class="webkit-html-tag">name</map>="Map"><area <span="" class="webkit-html-tag">shape="rect" coords="10,39,73,101" href="URL" target="_blank" alt="some text"> should this be <map <span class="webkit-html-tag">name</map <span>="Map"><area <span class="webkit-html-tag">shape</area <span>="rect" coords="10,39,73,101 <a <span class="webkit-html-tag">href="URL" rel="nofollow" target="_blank" alt="some text"></a <span> Want to check before I advise. If this is not the way how can I fix?
Web Design | | MickEdwards0 -
Redirection Of Mobile Traffic
Hi, I hope someone can help me with this, we have been working on creating a mobile version of our website, but does anyone know of a way of ensuring that mobile traffic is redirect to our mobile version, ie m.mydomain.com Thanks Rich
Web Design | | mos_rich0 -
RSS Submissions Positive/Negative/Neutral Impact...
We are looking to push our site content and blog content out to the masses... There are several sites and services that accept RSS feeds or submit RSS feeds to 50+ RSS sites. Have you seen an positive or negative impact of submitting feeds to these RSS directories? I am primarily looking at this for getting or content out and builing inbound links... Any thoughts or feedback would be appreciated... C
Web Design | | hireawizseo0 -
What site do you admire/like for its SEO - technical, content, whatever - and why?
I am gathering examples of great SEO'd sites and would appreciate your examples. The rationale can be anything - great SEO structure, great linking, solid content - you think stands out. Thank you!
Web Design | | josh-riley0 -
Random 302 Redirect (Wordpress CMS)
So this new project that i am working on is a redesigned CMS site using Wordpress (php based). Before i started on the project they made a few major updates that include: Changed from ID based URLS to SEO friendly URLS Added multiple languages in directories www.domain.com/en www.domain.com/fr www.domain.com/de etc... Due to the new languages they wanted to have the previous home page, www.domain.com, redirect to the proper language based on their IP address. Currently they are using a 301 redirect through a php header. So if i was visiting the site from my hometown of Cleveland, Ohio and i type www.domain.com into the browser. I would automatically redirect to www.domain.com/en and i would have the option to switch languages if needed. The issue: When i first added their site into SEOMoz the crawl returned a large amount of 302 redirects coming from their old homepage www.domain.com. So i took a look at the header calls using IE's webmaster tools and Firebug in Firefox. In both profilers it showed the same problem. Before the 301 header redirect there was a 302 redirect called first When viewing the response header it mentioned an x-pingback of some file that didn't even exist on the site: www.domain.com/xmlrpc.php This is obviously a huge issue because any link value from the old homepage will be lost due to the 302 not passing the value. I have tried search the almighty Google for help but it has gotten me no where. I have a hunch it is something to do with Wordpress but that is based on nothing but my gut. Any help is greatly appreciated. I got to get that 302 gone or changed to a 301 🙂 Regards - Kyle
Web Design | | kchandler0 -
Site Change / CMS Change
Hi Guys I have a very good client with whom we have been working with for over 2 years. When we 1st arrived, their website was built in Wordpress. During our SEO, the dleted the site and changed it to Drupal over night. Youc an imagin i went balistic and its been a horrid year in getting all the rrors down and redirects etc. Finally done I have just been informed that they will be deleting the website from Drupal to Joomla again! This is crazy as we have finally fix all the rrors and are driving quality traffic to the site. Now its back to square one... What do i do? ps the change from Drupal to Joomla is due to MYSQL issues
Web Design | | stefanok0