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
-
When moving a site from HTTP to HTTPS, will i lose value from the 301 redirect?
I am looking at moving my site from HTTP to full HTTPS, so i will 301 redirect any HTTP requests to their HTTPS counterpart. All my pages in the Google index are HTTP, so will that 301 redirect reduce the value of the pages? Cheers
Intermediate & Advanced SEO | | SEOhmygod0 -
New Site (redesign) Launched Without 301 Redirects to New Pages - Too Late to Add Redirects?
We recently launched a redesign/redevelopment of a site but failed to put 301 redirects in place for the old URL's. It's been about 2 months. Is it too late to even bother worrying about it at this point? The site has seen a notable decrease in site traffic/visits, perhaps due to this issue. I assume that once the search engines get an error on a URL, it will remove it from displaying in search results after a period of time. I'm just not sure if they will try to re-crawl those old URLs at some point and if so, it may be worth it to have those 301 redirects in place. Thank you.
Intermediate & Advanced SEO | | BrandBuilder0 -
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 -
Clarity needed on 301 redirects
Looking to get a bit of clarity on redirects: We're getting ready to launch a new website with a simplified url structure (we're consolidating pages & content) & I already know that I'll have to employ 301 redirects from the old url structure to the new. What I'm not clear about is how specifc I should be. Here's an example of my file structure: Old website: www.website.com
Intermediate & Advanced SEO | | JSimmons17
New website: www.website.com Old website: www.website.com/vacations
New website: www.website.com/vacations Old website: www.website.com/vacations/costa-rica
New website: www.website.com/vacations/central-america Old website: www.website.com/vacations/costa-rica/guanacaste
New website: www.website.com/vacations/central-america Old website: www.website.com/vacations/mexico
New website: www.website.com/vacations/central-america Old website: www.website.com/vacations/mexico/cancun
New website: www.website.com/vacations/central-america Old website: www.website.com/vacations/bolivia
New website: www.website.com/vacations/south-america Old website: www.website.com/vacations/bolivia/la-paz
New website: www.website.com/vacations/south-america Do I need to redirect each and every page or would just redirecting just the folder be enough to keep my SEO juice? Many thanks in advance for any help!0 -
How is my 301 redirected site stealing rankings from the main site?
Hello, I have a site, drhobelt.com, that 301 redirects to the main site, drhonow.com. Not only is drhobelt.com still indexed, but it recently stole rankings from drhonow.com for "decompression belt" related terms. What could be causing this? How do I reclaim the rankings for drhonow.com? Thanks for reading!!
Intermediate & Advanced SEO | | DA20130 -
301 redirect rule
Hi there, I have a website that has hundreds of links with a "question mark" at the end of URLs. For example: http://www.domain.com/directory/page.html?
Intermediate & Advanced SEO | | iQandil
http://www.domain.com/directory/another-directory?
http://www.domain.com/directory/yet-another-directory/? I'm want to place a wildcard redirect on the .htaccess file but don't know what exactly to add. Ideally I want the URLs above to be: http://www.domain.com/directory/page.html
http://www.domain.com/directory/another-directory/
http://www.domain.com/directory/yet-another-directory/ Any help is most appreciated. Thanks
Issa0 -
Time sensitive: HELP! We are having a problem doing a 301 redirect.....what can we do instead?
Our website has dynamic URLs and we are moving to another server/platform. 301 redirects is looking like a highly unlikely solution. A 3rd party company is handling the back-end of the website which they say works more like a "search engine" than a traditional website. Maybe that explains why they're having a hard time with the 301 redirects. Worst case scenario: we can't use the 301 redirect. What else can we do? We are considering "Indicate your canonical (preferred) URLs by including them in a Sitemap" as Google describes here: http://support.google.com/webmasters/bin/answer.py?hl=en&answer=139066#2. I'm wondering if this method only applies to duplicate content........and what would happen once the old website results in a 404 page...... HELP! We need to cross over to the new platform as soon as possible.
Intermediate & Advanced SEO | | PatriotOutfitters810 -
Redirect
Hi, I have one domain which was redirected today (the main domain,root) was redirected to a new subdomain of the main root domain.site was ranking for several keywords and had an authority of 35 on root domain. Site after 12 hours disappeared from google results.dont even rank for its brand name. What will happened to the new subdomain? Will rank again? Have the same keywords plus some more.old keywords are 3 and new are 2. For the old keywords on page optimization gets a c , and for the new a+c. For the new keywords don't have backlinks at all. When my site will start to rank for its old keywords? How long will be down ? Will pass the link juice and authority? If yes how soon ? Because I will loose to much money if stay longer like 1-2 weeks down. Thanks
Intermediate & Advanced SEO | | nyanainc0