301 redirect of a subdirectory
-
Hello!
I am working on a website with the following structure: example.com/sub1/sub2/sub3. The page "example.com/sub1" does not exist (I know this is not the optimal architecture to have this be a nonexistent page). But someone might type that address, so I would like it to redirect it to example.com/sub1/sub2/sub3.
I tried the following redirect: redirect 301 /sub1 http://example.com/sub1/sub2/sub3.
But with this redirect in place, if I go to example.com/sub1, I get redirected to example.com/sub1/sub2/sub3/sub2/sub3 (the redirect just inserts extra subdirectories).
If someone types "example.com/sub1" into a browser, I would "example.com/sub1/sub2/sub3" to come up. Is this possible?
Thank you!
-
Matt,
Our web designer just made a change within Expression Engine, our CMS, and it worked!
Here's the code:
{if segment_2 == "" && segment_3 == ""}{redirect="sub1/sub2/sub3"}{/if}He put the code at the very top of the main /sub1/ template. It means "if segments 2 and 3 are empty, forward to /sub1/sub2/sub3."Thanks again for your help!
-
Matt,
Thank you so much for your generous offer! I apologize for my delayed reply. I have had to turn my focus toward other issues and let this one go for the moment.
i really appreciate your support!
-
Hi - what other redirects do you have in place - could you stick them on here and perhaps I can help you make sure they don't conflict?
-
Matt,
Thank you very much.
I tried that code, but it seems to conflict with other redirects already in place. I will see what I can figure out.
-
This should do the trick
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteRule ^sub1 http://example.com/sub1/sub2/sub3 [R=301,NC,L]
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
-
Redirecting issue
Please I have a domain name miaroseworld.com I redirected (301 redirect) it to one of my domain names and I am having issues with the website so I decided to redirect to to my new site but moz is still showing redirecty to the previous websites
Technical SEO | | UniversalBlog
Even when I change the redirect on search console it still showing redirecting to the previous site.0 -
Buying a domain to 301 redirect for increased rankings
A large competitor has recently purchased a large marketing company that specializes in their industry. As a part of this acquisition they obtained ownership of www.digitalsherpa.com, which is now 301 redirecting some 50K links to www.costar.com/. When I did a site:www.digitalsherpa.com search all of the origin URLs had title tags from the costar site in place of their own. My question is: Does this violate Google spam guidelines? search?sourceid=chrome-psyapi2&ion=1&espv=2&ie=UTF-8&q=site%3Adigitalsherpa.com&oq=site&aqs=chrome.0.69i59j69i57j69i65j69i60j0l2.1919j0j7
Technical SEO | | Reis_Inc.0 -
301 redirects- how long to keep and how many are too many?
Hi, I was told we have way too many 301 redirects on our site. We have some that have been there for 3 years. Our site is datacard.com . Question- how long should you keep a redirect out there when building a new page and expiring an old page? Is it 6 months, is it a certain time frame? wondering what the best practices are? Thanks! Laura
Technical SEO | | lauramrobinson320 -
Creating a CSV file for uploading 301 redirect URL map
Hi if i'm bulk uploading 301 redirects whats needed to create a csv file? is it just a case of creating an excel spreadsheet & have the old urls in column A and new urls in column B and then just convert to csv and upload ? or do i need to put in other details or paremeters etc etc ? Cheers Dan
Technical SEO | | Dan-Lawrence0 -
Site blocked by robots.txt and 301 redirected still in SERPs
I have a vanity URL domain that 301 redirects to my main site. That domain does have a robots.txt to disallow the entire site as well. However, for a branded enough search that vanity domain still shows up in SERPs and has the new Google message of: A description for this result is not available because of this site's robots.txt I get why the message is there - that's not my , my question is shouldn't a 301 redirect trump this domain showing in SERPs, ever? Client isn't happy about it showing at all. How can I get the vanity domain out of the SERPs? THANKS in advance!
Technical SEO | | VMLYRDiscoverability0 -
How many steps for a 301 redirect becomes a "bad thing"
OK, so I am not going to worry now about being a purist with the htaccess file, I can't seem to redirect the old pages without redirect errors (project is an old WordPress site to a redesigned WP site). And the new site has a new domain name; and none of the pages (except the blog posts) are the same. I installed the Simple 301 redirects plugin on old site and it's working (the Redirection plugin looks very promising too, but I got a warning it may not be compatible with the old non-supported theme and older v. of WP). Now my question using one of the redirect examples (and I need to know this for my client, who is an internet marketing consultant so this is going to be very important to them!): Using Redirect Checker, I see that http://creativemindsearchmarketing.com/blog --- 301 redirects to http://www.creativemindsearchmarketing.com/blog --- which then 301 redirects to final permanent location of http//www.cmsearchmarketing.com/blog How is Google going to perceive this 2-step process? And is there any way to get the "non-www-old-address" and also the "www-old-address" to both redirect to final permanent location without going through this 2-stepper? Any help is much appreciated. _Cindy
Technical SEO | | CeCeBar0 -
301 redirect problems on site not yet moved
I have re-designed one of my sites, the old site is all static pages on a Windows server, I have made the new sites and it is on a new server and is running on Wordpress. I have just finished testing it and so am nearly ready to switch over the nameservers to the new server, however I'm having some problems with 301 redirects. I have tried to set up a few 301 redirects on the new server to test before I change nameservers but they don't appear to be working. I would have imagined that they should (even though the actual page isn't hosted on the new server) or am I being very stupid here and I can't test a 301 redirect until the nameservers have been changed. Redirect 301 /magazines.htm http://.../~account/magazine-freebies Obviously the above with the stars (*) is the server address and route to my account.
Technical SEO | | Wardy0 -
301 redirects twice
We currently have some 301 redirects set up on our site however sometimes a page will redirect twice before reaching the final location. Is this OK from an SEO perspective to have a page redirect twice or should we concentrate on reducing it to one?
Technical SEO | | JohnHillman0