× Here you can get community support related to ReDJ.

change redirect to account for new subcategory

  • bonaventure
  • Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
8 years 8 months ago - 8 years 8 months ago #4113 by bonaventure
I have a redirect that we tested in another thread that works perfectly to route urls from mydomain.com/aa-aa to mydomain.com/primary-category/29-aa-aa (where 29 is the article ID and aa-aa is the article alias.

I am now adding subcategories. So the new url has an extra category id and category name:
mydomain.com/primary-category/141-subcategory/29-aa-aa (where 141 is the subcategory ID and 29 is the category ID)

Here is the original redirect that works when there are no subcategories:
From URL: ^/[0-9A-Za-z\-]{5}$
To URL: {scheme}://{siteurl}/${category}/${id}-${alias}
Skip: /login$
Redirect: 200
Request Only: True
Placeholders: I'll attach photo because the forum won't allow database code.

How can I tweak the to URL so that it will go to an article whether it is in the primary category or subcategory.
By the way, all of the article alias's are unique (i.e., aa-aa is the only article with that alias), so perhaps there is a macro that can fill everything in between.
Attachments:
Last edit: 8 years 8 months ago by bonaventure.

Please Log in or Create an account to join the conversation.

More
8 years 8 months ago #4118 by admin
Hi,
probably you need another table lookup macro to retrieve the "141-subcategory" part, because it seems a brand new information to add in the target new URL. Can you check your tables to verify if it is possible to get this with a simple select?

Please Log in or Create an account to join the conversation.

  • bonaventure
  • Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
8 years 8 months ago #4128 by bonaventure
Replied by bonaventure on topic change redirect to account for new subcategory
Thank you so much for your fast response.
I thought of a solution that doesn't involve the redirect. Since the current formula already accounts for different categories at the root level, I simply placed the new category on the same level as the primary category (i.e., no parent). I'm pretty sure that I can grab the next level table with a simple select, but keeping them all on the same level will work better for my needs, plus I do not need to change the existing redirect.

This plugin is amazing! :)

Please Log in or Create an account to join the conversation.

More
8 years 8 months ago #4132 by admin
Thank you ;)

Please Log in or Create an account to join the conversation.

Time to create page: 0.103 seconds