Redirect and add Itemid
-
alebo
-
Topic Author
-
Offline
-
New Member
-
Less
More
-
Posts: 7
-
Thank you received: 0
-
-
11 years 1 month ago #1655
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.
Less
More
-
Posts: 3194
-
Thank you received: 441
-
-
11 years 1 month ago #1657
by admin
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.
-
alebo
-
Topic Author
-
Offline
-
New Member
-
Less
More
-
Posts: 7
-
Thank you received: 0
-
-
11 years 4 weeks ago #1671
by alebo
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.
Less
More
-
Posts: 3194
-
Thank you received: 441
-
-
11 years 4 weeks ago #1674
by admin
The following user(s) said Thank You: alebo
Please Log in or Create an account to join the conversation.
-
alebo
-
Topic Author
-
Offline
-
New Member
-
Less
More
-
Posts: 7
-
Thank you received: 0
-
-
11 years 3 weeks ago #1681
by alebo
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.
Less
More
-
Posts: 3194
-
Thank you received: 441
-
-
11 years 3 weeks ago #1684
by admin
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