How do I 301 Redirect a complete folder?
-
Hi,
I am want to delete a folder and all the contents. I then need to redirect anyone that is trying to reach a file in that folder to another page on my site.
example: www.mydomain.com/folder/ (contains 50 pages)
I want to delete the folder and all 50 pages.
So if someone tries to reach www.mydomain.com/folder/page1.php
the redirect would take them to a specific page on my site.
Doing this to clean up old content.
How would I do this on the .htaccess? I have redirected a page but not a folder.
Thanks in advance!
Force7
-
RewriteRule ^folder/(.*)$ http://www.newurl.com [R=permanent,L]
The above works for me.
-
I believe this is the way to go: RewriteRule ^OldFolder/?(.*) http://www.yourdomain.com/NewFolder/$1 [R=301,L] The $1 on the end of the URL appends anything extra after /NewFolder/ onto the new dir.
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
-
Can some sort of wildcard redirect be used on a single folder path?
We have a directory with thousands of pages and we are migrating the entire site to another root URL. These folder paths will not change on the new site, but we don't want to use a wildcard to redirect EVERYTHING to the same folder path on the new site. Setting up manual 301 redirects on this particular directory would be crazy. Is there a way to isolate something like a wildcard redirect to apply only to a specific folder? Thanks!
Intermediate & Advanced SEO | | MJTrevens0 -
URL Too Long vs. 301 Redirect
We have a small number of content pages where the urls paths were setup before we started looking really hard at SEO. The paths are longer than recommended (but not super crazy IMHO) and some of the pages get a decent amount of traffic. Moz suggests updating the URLs to make them shorter but I wonder if anyone has experience with the tradeoffs here. Is it better to mark those issues to be ignored and just use good URLs going forward or would you suggest updating the URLs to something shorter and implementing a 301 redirect?
Intermediate & Advanced SEO | | russell_ms0 -
Tough 301 redirect with a /www in it
Hi Mozzers, I'm using Eggplants 301 redirect via wordpress and for some reason I can't redirect one url. The example of it is below: www.website.com/news/www.website.com As you can see, it looks like there's 2 url's and this plugin doesn't do the trick. Does anyone have any suggestions? Maybe via .htaccess? Thank you!
Intermediate & Advanced SEO | | Shawn1240 -
To redirect or not to redirect, that is the question
I work for a software company that is redeveloping the website (same domain.) We have tons of content in the form of articles and documents for support, how to use the product better, case studies, and blog posts. I've downloaded a landing page report and many of these have low impressions and little or no clicks (some ranked high other very low.) Should I redirect all this content to the new site where some of it won't exist or forget about it because of the lack of juice? Is there a rule-of-thumb threshold for redirecting for content?
Intermediate & Advanced SEO | | Nobody15969167212220 -
Irrelevant backlinks - will 301 redirect cleanse the relationship?
My client has thousands of clients for whom they provided websites that used to reside in a subdirectory of their own domain. They moved them to their own domains but there are tens of thousands of backlinks on those sites pointing back to the original domain. Those backlinks are completely irrelevant and are probably hurting them by sending the wrong signals to Google on what this site really is about. My question is will the 301 redirect be enough to cleanse the relationship between my client and all their clients' sites or should I ask the client to clean up all those backlinks on their clients' sites and remove their domain from the target urls? That's a huge job, obviously.
Intermediate & Advanced SEO | | katandmouse0 -
Clarification around 301 redirects.
I’ve come across numerous blogs recently that suggest that SEOs should NOT do bulk re-directs to a category page. This has come as something of a surprise (doh!!) and I feel like I should already know this. It does seem like there is lots disagreement here so I thought that I’d ask what people’s opinions were to make sure that I get my thinking straight. I've read all the main Moz blog posts on this topic and, although really useful, they've left me none the wiser around a few specific questions. Here’s some more detail about the situation. We’re currently consolidating a lot of content into a main blog, which will be the focal point of new blogs posts that are created. This is different to the past, where we tended to create separate blogs for different products on separate domains. I’m currently considering how we move content across from one the older blogs to this new blog (which will soon sit on a subfolder of our main domain). I have three (!) questions: 1) Could you confirm that doing bulk re-directs a category page is bad? I already know that doing them all to the homepage is an error. 2) Should I re-direct the home page of the old blog on a separate domain to the relevant category page on the new site? The category page is related, but does not cover the EXACT topic. The category page covers our replacement product offering. It I shouldn't do this, where should I re-direct the old blog domain to? 3) I’ve recommended that we set up 301 redirects on a one-to-one basis, redirecting each piece of content to its new location on the old site. What about content that has been earmarked for removal and for which there is no obvious alternative? My previous recommendation has been to re-direct these pages to the most relevant category page on the new blog. Would it be better to let this 404 or, as an alternative, create a custom 404 for the users on the new blog highlighting the new content that we offer? Any help would be appreciated 🙂
Intermediate & Advanced SEO | | RG_SEO0 -
Home page url 301 redirect suggestion
Hello, In our site we have already done 301 redirect from http:// to http://www. However, the home page links are still coming in 2 ways http://www.mycarhelpline.com/ http://www.mycarhelpline.com/index.php?option=com_newcar&view=search&Itemid=2 Need suggestion We have already use rel canonical is another 301 redirect to be used for maintaining the home page pr from seo point of view. Does google still takes both urls as separate url and finds duplicate content
Intermediate & Advanced SEO | | Modi0 -
Does 301 Redirect works on social signals?
Hello, I'm considering strategic change in my site's formation.
Intermediate & Advanced SEO | | BeytzNet
301 redirecting some of the pages is not a problem but the question remains - what will happen with all of my social signals? These pages have Likes, plus ones, and tweets. Thanks0