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
-
Google is a definition engine / Question answering engine
But what do you do to rank when you sell a product and people don't have questions and none of the companies that rank on your keywords answers questions... Let me give you a few example. Title tag for example : People want to know what is it and then have question about it What is the maximum number of characters ? How do you write a good one ? Etc... How to remove stains is another example : Please want to know how to remove all the different types of stains, (ketchup, grease etc..) But what about when you are a online business and want to sell usb keys , rent bicycles https://www.spinlister.com or even sell a software to do A/B testing on your website https://bit.ly/2a6cBuF Can someone explain me how those people mentioned rank without giving definition or answering questions... because according to me they don't do any of that on the pages that I mentioned. I look forward to your reply. Thank you,
Web Design | | seoanalytics0 -
Requirements for mobile menu design have created a duplicated menu in the text/cache view.
Hi, Upon checking the text cache view of our home page, I noticed the main menu has been duplicated. Please see: http://webcache.googleusercontent.com/search?q=cache:http://www.trinitypower.com&strip=1 Our coder tells me he created one version for the desktop and one for the mobile version. Duplicating the menu cannot be good for on page SEO. With that said, I have had no warnings reported back from Moz. Maybe the moz bots are not tuned to looks for such a duplication error. Anyway, the reason the coder created a different menu for mobile in order to support the design requirements. I did not like the look and feel of the responsive version created based on the desktop version. Hi solution to this problem is to convert the Mobile version menu into ajax. what do you guys think? Thanks, Jarrett
Web Design | | TrinityPower0 -
Advanced 301 Redirects
Hi all! I'm moving a blog from a subdomain to a folder on my root domain and want to make sure I am properly implementing 301's. Is there a code or method for making specific pages 301 to the corresponding new URL without having to manually 301 each? For example, a current blog may exist at blog.website.com/3-tips-for-selling-your-home and, since we are moving the blog, will now exist at website.com/3-tips-for-selling-your-home. We obviously want to implement 301's to ensure any link equity carries over to the new url. Anyone know how to implement these in scale to without having to set up each manually? Thanks!
Web Design | | RickyShockley0 -
Main page redirect affecting search results?
Question.... A recent change was made to our page www.BGU.edu by a marketing person. So now when you type in www.BGU.edu it actually redirects to a different page www.BGU.edu/inquiry This is a really bad idea isn't it? I do not know enough about SEO to know a lot, and just joined SEOmoz but do I need to tell the admin to change it back?
Web Design | | nongard10 -
Comparing the site structure/design of my live site to my new design
Hi SEOmoz team, for the last few months I've been working on a new design for my website, the old, live design can be viewed at http://www.concerthotels.com - it is primarily focused on helping users find hotels close to concert venues throughout North America. The old structure was built in such a way that each concert venue had a number of different pages associated with it (all connected via tabs) - a page with information about the venue, a page with nearby hotels to the venue, a page of upcoming events, a page of venue reviews. An example of these pages can be seen at: http://www.concerthotels.com/venue/madison-square-garden/304484 http://www.concerthotels.com/venue-hotels/madison-square-garden-hotels/304484 http://www.concerthotels.com/venue-events/madison-square-garden-events/304484 http://www.concerthotels.com/venue-reviews/madison-square-garden-reviews/304484 The /venue-hotels/ pages are the most important pages on my website - and there is one of these pages for each concert venue - they are the landing pages for about 90% of the traffic on the website. I decided that having four pages for each venue was probably a poor design, since many of the pages ended up having little or no useful, unique content. So my new design attempts to bring a lot of the venue information together into fewer pages. My new website redesign is temporarily situated at: (not currently launched to the public) http://www.concerthotels.com/frontend The equivalent pages for Madison Square Garden are now: http://www.concerthotels.com/frontend/venue/madison-square-garden/304484 (the page above contains venue information, events and reviews) and http://www.concerthotels.com/frontend/venue-hotels/madison-square-garden-hotels/304484 I would really appreciate any feedback from you guys, based on what you think of the new site design compared to the old design from an SEO point of view. Of course, any feedback on site speed, easy of use etc compared to the old design would also be greatly appreciated. 🙂 My main fear is that when I launch the new design (the new URLs will be identical to the old ones), Google will take a dislike to it - I currently receive a large percentage of my traffic through Google organic search, so I don't want to launch a design that might damage that traffic. My gut instinct tells me that Google should prefer the new design - vastly reduced number of pages, each page now contains more unique content, and it's very much designed for users, so I'm hoping bounce rate, conversion etc will improve too. But my gut has been wrong in the past! 🙂 But I'd love to hear your thoughts, and thanks in advance for any feedback, Cheers Mike
Web Design | | mjk260 -
Redirect based on location best practice clarification?
Hi, i have a question that i have seen some other have also had. The question is what is the best practice to serve the location specific page to the user (based on their location)? This post (http://www.seomoz.org/q/redirecting-users-based-on-location) suggests against automatically redirecting the user based on IP address. I guess the primary concern is that Google bot will also be redirected in this case... I see a number of well known sites use automatic redirect based on location. Take Urbanspoon for example (http://www.urbanspoon.com/), they use a 302 redirect to redirect to location specific page. Do they not redirect Google bot? Is there any way to test this? Can creating a rule to exclude crawlers from redirect cause SEO problems? How? Another example that i am somewhat confused as to how it works effectively is groupon.com.au It selects my closest city (i assume using IP), however the URL stays as the root URL. For example, i typed in http://www.groupon.com.au/ and it stays as http://www.groupon.com.au/ with the city chosen as "Melbourne". The canonical url for this page is the root URL (ie http://www.groupon.com.au/). If you then select "change city" and click the same city (ie Melbourne), it redirects to http://www.groupon.com.au/deals/melbourne. Canonical URL of this page is http://www.groupon.com.au/deals/melbourne. How is this not duplicate content? Can you please advise on the best way to redirect (ideally automatically), to provide the best user experience, while still having Google bot able to crawl the site effectively? Thanks
Web Design | | blackrails0 -
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 -
For a new business which would be the best domain name?
I'm starting a new business selling Whitby Jet and I want to buy the best domain name which will help me in the search engines, I want to use the keywords in the domain name because it think it will help when people link to the website, but whitbyjet.com and whitbyjet.co.uk have both been taken. I could be wrong I think .com is generally thought of as the best and I don't really like the idea of .net or .org So maybe I might have to choose the third word which tends to make the doamin a little bit longer like whitbyjetjewlery.co.uk. Any suggestions would be greatly received.
Web Design | | whitbycottages0