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
-
Domain name change
Dear team, If a website with a domain name - example - raisins.com wishes to change to peanuts.com is this a dangerous task or a relatively simple one? I hope that by keeping my Q short, provides ease.
Web Design | | AdrianCGreen0 -
Can multiple domains compete with one another if they have the same/similar content?
Could an ecommerce site with a .co.nz nd .com.au domain compete with one another and hard organic rankings if the content of the pages are the same? All the links would be identical (apart from .co.nz or .com.au) the product descriptions, pages titles etc... would all be identical or similar (our page titles are ever so slightly different). Could this be hurting us? Thanks in advance ^ Paul
Web Design | | kevinliao0 -
Best way to move blog from subdomain to folder?
Hey all, Our company has 4 product websites, and each has its own separate blog. They are currently set up as subdomain blogs (blog.company.com) hosted on wordpress.com, but I would like to transition them over to root folders (company.com/blog) in order to improve accessibility and SEO. What is the best way to go about doing this? Should I continue to host the blogs on wordpress or are there better options? Would I migrate the blog posts over or just redirect? I'd like to get a general framework/plan of action going in order to know what to expect. Thanks!
Web Design | | kslusarski0 -
Does Google count the domain name in its 115-character "ideal" URL length?
I've been following various threads having to do with URL length and Google's happiness therewith and have yet to find an answer to the question posed in the title. Some answers and discussions have come close, but none I've found have addressed this with any specificity. Here are four hypothetical URLs of varying lengths and configurations: EXAMPLE ONE:
Web Design | | RScime25
my-big-widgets-are-the-best-widgets-in-the-world-and-come-in-many-vibrant-and-unique-colors-and-configurations.html (115 characters) EXAMPLE TWO: sample.com/my-big-widgets-are-the-best-widgets-in-the-world-and-come-in-many-vibrant-and-unique-colors-and-configurations.html (126 characters) EXAMPLE THREE: www.sample.com/my-big-widgets-are-the-best-widgets-in-the-world-and-come-in-many-vibrant-and-unique-colors-and-configurations.html (130 characters) EXAMPLE FOUR: http://www.sample.com/my-big-widgets-are-the-best-widgets-in-the-world-and-come-in-many-vibrant-and-unique-colors-and-configurations.html (137 characters) Assuming the examples contain appropriate keywords and are linked to appropriate anchor text (etc.,) how would Google look upon each? All I've been able to garner thus far is that URLs should be as short as possible while still containing and contextualizing keywords. I have 500+ URLs to review for the company I work for and could use some guidance; yes, I know I should test, but testing is problematical to the extreme; I look to the collective/accumulated wisdom of the MOZVerse for help. Thanks.1 -
301 redirect on Windows IIS. HELP! (Part 2)
My webmaster's trying (but struggling) to 301-redirect the non.www version of my site to the www version. He's following these instructions given to me in a response to an SEOMoz Private Question (ah, the good old days!). So far he's 301-redirected the homepage but seems stuck on how to do the entire site. Any clues on what he should be doing?
Web Design | | Jeepster0 -
Website Updates, will this affect my ranking/ DA or PA?
Hello All! My website is due for a big update soon, my current site is doing ok, however I want to update all of the content, structure, style and look of my whole site. I feel that with the way it's been going lately that it's time for an upgrade, my question is, will this affect my ranking? Will my page ranking's be affected? Will my DA be affected? I intend to optimize this new website perfectly too with all the things I've learnt since joining this forum. All the best, Paul
Web Design | | Paul_Tovey0 -
Duplicate home page /index.asp /index.php etc
We recently moved www.devoted2vntage.co.uk to shopify but seem to have multiple home page variants still in google index. I am concerned that these will be causing duplicate content. I have redirected the offending URLs below to www.devoted2vintage.co.uk/ and have set up a canonical URL but need an expect to tell me if I have taken the current steps and if not, exactly what I need to do. www.devoted2vintage.co.uk/index.php www.devoted2vintage.co.uk/index.htm www.devoted2vintage.co.uk/index.html www.devoted2vintage.co.uk/index.shtml www.devoted2vintage.co.uk/index.aspx www.devoted2vintage.co.uk/index.cfm www.devoted2vintage.co.uk/index.pl www.devoted2vintage.co.uk/index.asp
Web Design | | devoted2vintage0 -
Link Pages/Directory
Hello, What is best practise for dealing with alot of links. I was thinking of breaking them download to alphabet pages i.e. all A on one page etc... BUT should I then make the links clickable on this list OR that they load to a sub company page which has a clickable link to there website.
Web Design | | JohnW-UK0