× Here you can get community support related to ReDJ.

Help with redirect

  • mkrokos
  • Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 5 months ago - 7 years 5 months ago #2895 by mkrokos
Help with redirect was created by mkrokos
Hello, I have recently changed the URL structure of my website and now I am getting lots of 404 errors.

The previous form of the URL was like this:

lovecooking.gr/συνταγές/μαγειρική/1381-Mοσχαρίσιο-φιλέτο-ψητό
or
lovecooking.gr/συνταγές/μαγειρική/item/1381-Mοσχαρίσιο-φιλέτο-ψητό
or
lovecooking.gr/συνταγές/μαγειρική/μοσχάρι/1381-Mοσχαρίσιο-φιλέτο-ψητό

which contained greek characters and made the URL really long and unfriendly when used in posting to Facebook or other.

The new form of URL is:
www.lovecooking.gr/syntages/mageiriki/1381-mosxarisio-fileto-pshto

But even that would also suffice:
www.lovecooking.gr/index.php?option=com_k2&view=item&layout=item&id=1381

Could you pls assist me with creating a dynamic redirect that applies to all URLs of that form?

Kind regards,
Manos K
Last edit: 7 years 5 months ago by mkrokos.

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

More
7 years 5 months ago - 7 years 5 months ago #2897 by admin
Replied by admin on topic Help with redirect
Hi Manos,
it is possible but first I need some additional information.

1) You could create a rule for each category / subcategory (i.e. the destination includes statically /syntages/mageiriki/) or do you want to set them dynamically (looking up the database) and have just a single rule (more complex)?

2) The key to connect old URLs to new ones is the id (i.e. 1381). We could lookup the database to get the alias mosxarisio-fileto-pshto and build the destination. Could you check if this is the K2 alias?

Kind regards,
Luigi
Last edit: 7 years 5 months ago by admin.
The following user(s) said Thank You: mkrokos

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

  • mkrokos
  • Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 5 months ago #2899 by mkrokos
Replied by mkrokos on topic Help with redirect
Hello Luigi and thanks for the reply!

I am sorry but I don't understand exactly what you mean. But I will show you the tree structure and you might understand how it goes:

Syntages (parent category, means 'recipes' in greek)
- mageiriki (child category, means 'cooking')
- zaxaroplastiki (child catefory, means 'pastry' or 'confisserie')
- pota (child category, means 'drinks')

so the destination includes 'syntages' (almost 95% of the times) and then one of the three children categories.

Then follows the item id (ie, 1381) and then the item alias (mosxarisio-fileto-pshto) separated by a dash (-)

Is that sufficient information?

Kind regards,
Manos K

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

  • mkrokos
  • Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 5 months ago - 7 years 5 months ago #2900 by mkrokos
Replied by mkrokos on topic Help with redirect
Also this form should be added to the list of "From URL" (yet another subcategory followed by '/item')

lovecooking.gr/συνταγές/μαγειρική/μοσχάρι/item/1381-Mοσχαρίσιο-φιλέτο-ψητό

('μοσχάρι' stands for 'veal') ;)
Last edit: 7 years 5 months ago by mkrokos.

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

More
7 years 5 months ago #2901 by admin
Replied by admin on topic Help with redirect
Hi Manos,
what you want to do is possible but not so easy (and almost impossible without database access). I try to explain you how to create the rule (you need to play with macros and placeholders). The rule should be:
From URL: ^/συνταγές/μαγειρική/
To URL: http://{siteurl}/syntages/mageiriki/${id}-${alias}
Decode URL. true (checked)
Request only: true (checked)

Now you need to define the placeholders:
id={preg_match 1}/\/([0-9]+)-/i{/preg_match}
alias={placeholder_select #__k2_items,alias,id=id}

But you should check the alias placeholders if is right for your database.

Kind regards,
Luigi
The following user(s) said Thank You: mkrokos

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

  • mkrokos
  • Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 5 months ago - 7 years 5 months ago #2902 by mkrokos
Replied by mkrokos on topic Help with redirect
Hello Luigi, come stai?

I have tried what you suggested but the returning URL produces a 404 error because it isn't decoding the preg expression or something:

The resulting link

Actually, I can't paste the URL here without it being translated but you see what I mean.

Kind regards,
Manos K
Last edit: 7 years 5 months ago by mkrokos.

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

Time to create page: 0.136 seconds