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
-
Using a Reverse Proxy and 301 redirect to appear Sub Domain as Sub Directory - what are the SEO Risks?
We’re in process to move WordPress blog URLs from subdomains to sub-directory. We aren’t moving blog physically, but using reverse proxy and 301 redirection to do this. Blog subdomain URL is https://blog.example.com/ and destination sub-directory URL is https://www.example.com/blog/ Our main website is e-commerce marketplace which is YMYL site. This is on Windows server. Due to technical reasons, we can’t physically move our WordPress blog to the main website. Following is our Technical Setup Setup a reverse proxy at https://www.example.com/blog/ pointing to https://blog.example.com/ Use a 301 redirection from https://blog.example.com/ to https://www.example.com/blog/ with an exception if a traffic is coming from main WWW domain then it won’t redirect. Thus, we can eliminate infinite loop. Change all absolute URLs to relative URLs on blog Change the sitemap URL from https://blog.example.com/sitemap.xml to https://www.example.com/blog/sitemap.xml and update all URLs mentioned within the sitemap. SEO Risk Evaluation We have individual GA Tracking ID and individual Google Search Console Properties for main website and blog. We will not merge them. Keep them separate as they are. Keeping this in mind, I am evaluating SEO Risks factors Right now when we receive traffic from main website to blog (or vice versa) then it is considered as referral traffic and new cookies are set for Google Analytics. What’s going to happen when its on the same domain? Which type of settings change should I do in Blog’s Google Search Console? (A). Do I need to request “Change of Address” in the Blog’s search console property? (B). Should I re-submit the sitemap? Do I need to re-submit the blog sitemap from the https://www.example.com/ Google Search Console Property? Main website is e-commerce marketplace which is YMYL website, and blog is all about content. So does that impact SEO? Will this dilute SEO link juice or impact on the main website ranking because following are the key SEO Metrices. (A). Main website’s Avg Session Duration is about 10 minutes and bounce rate is around 30% (B). Blog’s Avg Session Duration is 33 seconds and bounce rate is over 92%
Intermediate & Advanced SEO | | joshibhargav_200 -
How long does Google take to completely authorise 301 redirect?
Will 301 redirect will have immediate impact once the website or that redirected link got indexed? We have recently redirected few links in the process of link reclamation and ranking dropped few days later. Every link we claimed is related to our topic (matched in content and URL) and they have good DA. Even though why it has happened? What are the general rank dropping factors in the process of link reclamation? Thanks, Satish
Intermediate & Advanced SEO | | vtmoz0 -
Can I undo a 301 redirect? Will it penalize my ranking?
I'm in charge of building a website for a company that made a mess. They own domain xxx.it (xxx is not the real domain, just a placeholder). Some years ago they 301 redirected xxx.it to xxx.com (they just changed TLDs). Last year they 301 redirected xxx.com to yyy.com (so, they actually changed domains). Now, after 13 months, the company failed and the new leadership wants me to undo everything and 301 redirect from yyy.com to xxx.it. So: 301 redirect is permanent. So, conceptually it's wrong to undo it. What happens if I undo it? Will my ranking be penalized, even if a significant amount of time has passed (13 months)? Will crawlers detect a loop (even if i remove any 301 redirect from xxx.it and theorically break the loop)? Here is the potential loop: xxx.it -> xxx.com -> yyy.com -> xxx.it -> etc... All of the articles I found on the web are quite old and not clear about this topic, that's why I'm asking this question.
Intermediate & Advanced SEO | | naska19900 -
This redirect has me racking my brain
I cannot tell if something is wrong with my domain redirect or if it is some default behavior by Chrome. I made a short video, I used Moz first since they are using an SSL certificate too. But the gist is immediately when I type in the address it flashes www, then redirects to the non www. domain. Because of how its happening so quick I cannot tell if this is just default Chrome behavior or if I have the DNS set up incorrectly. Here is the video. http://screencast.com/t/UDHmdTCbQv
Intermediate & Advanced SEO | | LesleyPaone0 -
When should you redirect a domain completely?
We moved a website over to a new domain name. We used 301 redirects to redirect all the pages individually (around 150 redirects). So my question is, when should we just kill the old site completely and just redirect (forward/point) the old domain over to the new one?
Intermediate & Advanced SEO | | co.mc0 -
301 vs 302
We recently launched a redesign and I noticed from running a crawl using Screaming Frog SEO that our redirects are all being seen as 302. I know 302 is a temporary redirect, but does this hurt SEO rankings when all our redirects are being seen as 302s instead of 301s? Also, the way I implemented the redirects was by using the IIS Manager Tool. Is it possible that our IIS Manager Tool is not configured properly and instead of adding the redirect as 301, it is inserting it into the rewrite file as 302s?
Intermediate & Advanced SEO | | rexjoec0 -
Redirect 301
Hi, I `m redirecting some pages in htaccess The first 15 pages that i redirected it worked. But the last 3 dont work, and i cant figure it out why it is not working. Redirect 301 /analyseverktoy/ /webanalyse
Intermediate & Advanced SEO | | SGacic
Redirect 301 /index.php/ledige-stillinger/ /
Redirect 301 /?page_id=352/ / Anu suggestions?0 -
SEO vs 301
I have a website about "Download of games" and im planning open one about "games online" i know that "games online" its super hard to get good ranks, soo im thinking and do a 301 from my website of "download games" to my new website, do you think that is a good strategy ?
Intermediate & Advanced SEO | | nafera21