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
-
Is 301 redirects a deal breaker for Migrating content or moving to new software?
I have this forum with about 2 million posts for 16 years on root of the domain. I am looking to switch softwares but the top ones won’t help setup 301 redirects. But I can still migrate all my members and all my content (threads/posts), would Google still reindex all our content or if we don’t setup redirects would it really kill our entire traffic for a long time or maybe just a month or so? I really want to migrate to software that isn’t forum based but rather something that offers courses, chat, live video streaming, subscription based etc. and this is the only way to do so OR to set it up on an entirely new domain OR subdomain but to me that is like starting all over from scratch? I could archive the forum to read only and set it up on subdomain or another root domain - then on the archived forum setup banners and a pop up linking to the new site or new subdomain? . This is such a hard decision for us as the current forum we have had for so many years has lost members posting from 1k a day to just a handful a day, our fb group though gets 1k a day so I’m trying to revive a site into something more modern and has all the training features we can offer as well.
Technical SEO | | vbsk1 -
Is 301 redirect the only way when using Vanity URLs?
We have been using vanity urls for some of our pages. Mostly the pages that have a vanity URL have a long URL length. But now the problem is, the vanity URL is getting displayed on the search engine when the particular keyword related to the page is entered. I checked the google search console, the vanity URL is indexed and the original URL remains unindexed. What should I do? Is adding 301 redirect to the vanity URLs are solution? Since some of vanity URLs are not redirecting to the original. Some of the original pages are not getting traffic. Also, can using canonical tag help?
Technical SEO | | tejasbansode0 -
301 redirecting a previously abused URL
A client previously had their most important landing page at domain.com/example.htm They carried out the sort of link building that was commonplace a few years back (exact match anchors, paid blog links etc) targeting this URL, but they also got a bunch of legitimate decent quality links here. I believe they may have had a number of issues when link quality algo updates were rolled out, so rather than try and get links removed and go through the disavow process they instead decided to abandon this URL, let it 404 and start afresh at domain.com/example.html - updating all internal navigation, XML sitemaps etc. So fast forward to today. What is the best practice for this URL these days do we think? Is it now possible to 301 domain.com/example.htm > domain.com/example.html and recover whatever value may be left here? The argument for not doing so may be that you could pass over the negative metrics associated with the old URL, but would this not be handled by the real-time penguin update and the poor links just devalued rather than actually harming? And could this just be tested - i.e. add in the 301, monitor the impact and if things don't go the way we'd want then just remove the 301 again? Would be keen to get a few opinions on this. TIA
Technical SEO | | Salience_Search_Marketing0 -
301 redirect with Magento; still Page authority 0 after 6 weeks
Hi Mozzers! In December '14 I have execute a 301 redirect in the 'old' page in the admin of my Magento store. Now I was surprised to see that the Page Authority is still 0 of the new page 6 weeks after the execution. should I have seen the update of the PA on the new page already after 6 weeks of time? If yes, then I assume that my Magento didn't execute this properly? Old url: http://hippemamashop.nl/mama/boeken/fotoalbum.html
Technical SEO | | aznventure
New page: you will be redirected to the new page after clicking the old page Mm4uBEl0 -
Existing content & 301 redirects
Hi All, I will try to keep this to the point. One of our websites was hit by penguin for unnatural linking. We are building a new site (same business, different domain), but we would like to take some of the pages/content off the old website and use it on our new site. Is it just a case of copying each page onto our new site and 301 redirect the old URL? Or should I just be completely rewording/recreating the old content so it is unique? Any help on this would be great, but I am also open to alternate methods too. Thanks Lewis
Technical SEO | | SO_UK0 -
Does it really matter to set 301 redirect for not found error pages?
I've very simple question for not found error pages. Does it really require to set up 301 redirect for all not found error pages which detected in Google webmaster tools? Honestly, I don't want to set 301 redirect exclude externally connected pages. So, what will impact on ranking after follow this process?
Technical SEO | | CommercePundit0 -
Do 301 redirects pass page rank quickly
Hi I have been asked to carry out a site audit for a potential client. The site has that many issues I don't where to start in explaining them however, there is one question we are debating and would like to get a second opinion on it. The site I am auditing used to have a homepage rank 7. The site has currently had a redesign (new template with new URLs) and now the root domain 301 redirects to a sub folder two levels deep (not ideal I know!). This happened about a month ago and we are still getting N/A for toolbar page rank. The question is, does Google page rank transfer quicker than normal due to the redirects? or do we still have to wait on the next Google Page Rank update? Thanks in advance Gavelect
Technical SEO | | Equatorites0 -
301 redirect while keeping OLD domain for branding
Say you have CharityName.com. They use a dedicated domain name CharityNameEvent.com to advertise their main event. They use this domain on posters, flyers,etc and want to keep using it because it's easier to remember. CharityNameEvent.com has far, far more inbound links than CharityName.com (about 8 times more). Current problem: their current web developer has put the SAME content on both websites instead of setting up a redirect from CharityNameEvent.com (easy to remember) to CharityName.com/Event which would have made more sense. My intention is to consolidate the 2 websites and make sure CharityName.com benefits from links to the Event. I plan to move and 301 redirect CharityNameEvent.com to CharityName.com/Event. I know this would keep links and PR intact but I have a couple of questions: 1. Is it enough to set up the 301 redirect or would they have to ask websites to ACTUALLY change the links to CharityName.com/Event? 2. They plan and need to keep using CharityNameEvent.com for its ease of use on posters, flyers, etc. The 301 redirect would be in place. Would this cause any problems with search engines, especially when/if some people STILL link to CharityNameEvent.com instead of CharityName.com/Event? Basically, my understanding of 301 redirects is that they're used when a website permanently moves. In this case, the OLD DOMAIN name would still be used for reasons mentioned above but would be 301 redirected to CharityName.com/Event. Any chance this might not maximise the potential of new/old links? Any other way to go about it? Anything I'm missing with this scenario? Thanks
Technical SEO | | carmenmardiros0