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
-
Suddenly Many 301 Redirects captured by SEOMOZ
On April the 7th SeoMOZ captured 6000 301 redirect on my site, but I cant seem to understand how SEOMOZ finds these links Example http://www.iphonegadget.dk/dk/apple-tilbeh-r-36/ipad-tilbeh-r-219/bilholder-239/index-2-4a.html Makes a 301 Redirect to the following page beneath SEOMOZ says http://www.iphonegadget.dk/dk/apple-tilbeh-r-36/ipad-tilbeh-r-219/bilholder-239/index-2.html The weird thing is that both urls work, but if i browse my site in a normal matter this link will never be created i that way. The -4a in the end os the link is not the normal link structure on the site and has never been like that before. So how does SEOMOZ Create that link? http://www.iphonegadget.dk/dk/apple-tilbeh-r-36/ipad-tilbeh-r-219/bilholder-239/index-2-4a.html Also google only has the right one that are this one beneath http://www.iphonegadget.dk/dk/apple-tilbeh-r-36/ipad-tilbeh-r-219/bilholder-239/index-2.html People would normal come to the category with this url http://www.iphonegadget.dk/dk/apple-tilbeh-r-36/ipad-tilbeh-r-219/bilholder-239/ And page 2 would be http://www.iphonegadget.dk/dk/apple-tilbeh-r-36/ipad-tilbeh-r-219/bilholder-239/index-2.html AND NOT http://www.iphonegadget.dk/dk/apple-tilbeh-r-36/ipad-tilbeh-r-219/bilholder-239/index-2-4a.html Can anyone find out what is going on?
Technical SEO | | noerdar0 -
How does this rank? - a page that is 301 redirected
How does a 301ed page rank in google? In google I searched for" ikea.ca" which is set up as a 301 redirect to www.ikea.com/ca/en and was surprised to see the url --> www.ikea.ca actually ranking. IKEA Canada <cite>ikea.ca/</cite>IKEA Featuring Scandinavian modern style furniture and accessories. Include storage options, lighting, decor products, kitchen appliances and beds. Bedroom - Kitchen - Living Room - IKEA North York
Technical SEO | | Morris770 -
What factors matters the most when using a 301 permanent redirect?
Hi SEOmozzers, I have a client that has couple of duplicates but I am debating if i should just kill those pages or use 301 Permanent redirects. I know SEO moz provides 2 important factors to look at which are PA and link root domain. 1.Which one matters the most? or which one should I look at first to make a decision? 2. I have empty pages creating duplicate content with a PA of 14 and 1 linking root domain. my thought is to kill the page by inserting a meta NO INDEX. If you don't agree and think I should 301 to an existing page that needs link juice, let me know. Thank you mozzers 🙂
Technical SEO | | Ideas-Money-Art0 -
Should I change a 301 redirect?
I recently moved all the content from an old site to a new site on a new domain. I lost a significant amount of traffic as a result. There are 301 redirects for every page on the old site. Generally, these point to the same content as was on the relevant page of the old site. However, the 301 redirect for the homepage on the old site points to the homepage on the new site, not to the content from the old site homepage. I'm wondering whether to change the 301 to point at the content from the old site homepage. Any advice would be much appreciated.
Technical SEO | | seqal0 -
Can I do a redirect to a new domain name only a couple of weeks after having redirected to another domain?
I have a client with two website with very similar content. Both had a lot of inbound links and performed fairly well in SERPS. We recently combined both sites and have redirected one of the domains to the other. The traffic dipped slightly initially, but is recovering nicely. Now the client registered a new domain name he would like to use for the site. Should I wait a few weeks for everything to settle down after the first redirect/consolidation of sites before doing a new redirect to a new domain name, or should I not worry about having any issues with doing it right away?
Technical SEO | | Drewco0 -
301 redirect
What is a proper way to redirect any url containing a give word (anywhere in the url) to another sepcified url? Is it like this? RedirectMatch 301 ^thisword$ http://domain.com/newlocation
Technical SEO | | sesertin1 -
301 Redirects
Last year we merged 3 websites into 1 website and launched the new site in February. When developing the new site I created 301 redirects for all the pages from the old sites to the new site. Unfortunately when the new website was created the URLs were not optimised for search engines. I now need to optimised the page URLs. In theory I need to create new 301 redirects from this existing pages to the new optimised URLS. I am concerned that in a few years I might end up with a string of 301 redirects and if I break some links I might loose some ranking. How many redirects will link juice work for? I hope I'm clear here, if not I've attached a image showing what I'm doing. Thank you. unledfh.jpg
Technical SEO | | Seaward-Group0 -
Should I move x-cart installation or 301 redirect?
We have an existing e-commerce site built on x-cart. The default store location is www.site.com/store. The domain root however is just a static HTML page (currently using mainly graphics) and a nav menu. What would be a better option: 1. Move the install location to the root directory and get rid of the static HTML page. We would have to manually 301 redirect all the old pages to the new location. Not sure if there are negative implications with that. 2. Just optimize the HTML landing page? Seems like it is better to have products and categories as close to the root domain as possible... 3. 301 redirect the domain to www.site.com/store/ and optimize the homepage within the store. This option means we dont have to worry about 2000 redirects or the hassle of moving the store. Anyone had any experience with this and suggestions?
Technical SEO | | BlinkWeb0