× Here you can get community support related to ReDJ.

Redirect and add Itemid

More
11 years 1 month ago #1655 by alebo
Redirect and add Itemid was created by alebo
Can you help a regex beginner out.

I need to set up a redirect to add an ?Itemid=550 to these urls. I believe I should be able to do this with one statement.

Current URLs
/component/cobalt/category-items/1-directory/9-marine-science
/component/cobalt/item/9-marine-science/73-black-bryan-a?Itemid=289

End result I would like them to be
/component/cobalt/category-items/1-directory/9-marine-science?Itemid=550
/component/cobalt/item/9-marine-science/73-black-bryan-a?Itemid=550


First I need to check if they start with /component/cobalt/. ^(/component/cobalt/)
I don't know how to handle the end part. Some of the urls have an Itemid already and some do not.

I think that my 'To URL' field would be {pathfrombase}?Itemid=550 but I am not sure.

Please advise. Thanks.

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

More
11 years 1 month ago #1657 by admin
Replied by admin on topic Redirect and add Itemid
Try this:
From URL: ^/component/cobalt/
To URL: {scheme}://{siteurl}{path}?Itemid=550&{query}

Kind regards,
Luigi

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

More
11 years 4 weeks ago #1671 by alebo
Replied by alebo on topic Redirect and add Itemid
Thanks, however there is one piece of this puzzle I have accidentally left out.

I have many urls like below that need to be left alone.
/component/cobalt/category-items/1-directory/9-marine-science?option=com_cobalt&task=records.filter&ion_id=1&filter_name[0]=filter_cat&filter_val[0]=9&filter_name[1]=filter_k00d30fd9c5f095b1aa56604535dccad8&filter_val[1]=Staff

Is it possible to modify the previous code you provided to ignore when the {query} = '?option=com_cobalt'

Thank you so much for you help. It is greatly appreciated.

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

More
11 years 4 weeks ago #1674 by admin
Replied by admin on topic Redirect and add Itemid
Hi,
you are trying to build a so called "negative look ahead assertion" that is not supported by MySQL regexp but could be simulated (not so easy). A similar question in this post:

www.sistemistica.it/forum/11-redj-in-english/2860-negative-lookahead-assertions.html

I was looking for a way to add "conditional rules" in future version, it should be more confortable... :)

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

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

More
11 years 3 weeks ago #1681 by alebo
Replied by alebo on topic Redirect and add Itemid
Hi Luigi,

I am going back to your original advise, however when I use the code below I get an error that the redirect is directing in a way which will never succeed. I believe that this is because the 'To URL' is getting caught again in the 'From URL' as it still matches. Any ideas on how to make this work?

Try this:
From URL: ^/component/cobalt/
To URL: {scheme}://{siteurl}{path}?Itemid=550&{query}


Thanks very much for your help.

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

More
11 years 3 weeks ago #1684 by admin
Replied by admin on topic Redirect and add Itemid
Sorry,
you are right, to avoid loops you should not match URLs with "Itemid=". Unfortunately is not so easy to specify so called "negative lookahead assertions". I will add a feature to support this kind of rules in the next version.

Kind regards,
Luigi

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

Time to create page: 0.137 seconds