× Here you can get community support related to ReDJ.

Complex Redirect Rule

  • donald
  • Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
More
9 months 4 weeks ago #6600 by donald
Complex Redirect Rule was created by donald
Hi,

I'm not sure if this topic exist and I'm not sure if this is possible to create 1 rule and applies to all. What I'm trying to do is. I have so many different urls but usually they have the same end and I want the last end which is "all" to be remove on new/redirect url. for example

from source
www.domain.com/directory/ottawa/food/restaurant/all
www.domain.com/directory/toronto/food/bakery/all
www.domain.com/directory/montreal/multimedia/photography/all

to new url
www.domain.com/directory/ottawa/food/restaurant/
www.domain.com/directory/toronto/food/bakery/
www.domain.com/directory/montreal/multimedia/photography/

Is it possible to create 1 rule and applies to all?
source: http://{siteurl}/*/*/*/*/all*$
new: http://{siteurl}/*/*/*/*/

Hoping to see your soonest reply.

Thank you

Best regards,
Donald

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

More
9 months 3 weeks ago #6612 by admin
Replied by admin on topic Complex Redirect Rule
Hi Donald,
it's quite simple with ReDJ rules:
From URL: /all$
To URL: {scheme}://{siteurl}{pathrtrim /all}{queryfull}

Kind regards,
Luigi

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

  • donald
  • Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
More
4 months 5 hours ago - 4 months 4 hours ago #6868 by donald
Replied by donald on topic Complex Redirect Rule
Thank you for your previous response, I never ended up using the site is restructured now.

I'm trying to do something else though, and i'm struggling with placeholders

I have so many different urls but they have the same pattern. I would like to add a city parameter for each one based on the city in the path. For example:

from source
www.domain.com/directory/ottawa/food/restaurant/all
www.domain.com/directory/toronto/food/bakery/all
www.domain.com/directory/kitchener-waterloo/multimedia/photography/all

to new url
www.domain.com/directory/ottawa/food/restaurant/all?cf43 [0]=ottawa
www.domain.com/directory/toronto/food/bakery/all?cf43 [0]=toronto
www.domain.com/directory/kitchener-waterloo/multimedia/photography/all?cf43 [0]=kitchener-waterloo

Notice how the cf43[0]=<city> is the same as the city in /directory/<city>. Also note that there is no space after cf43, but the editor in this forum shows that there is for some reason.


Is it possible to create 1 rule and apply to all matching urls?

Here is what I did so far, but does not work. What am I doing wrong?

source: ^/directory/([a-zA-Z-]+)/(\w+)/(\w+)/all$
new: {scheme}://{host}/directory/${city}/${cat}/${subcat}/all\?cf43\[0\]\=${city}

placeholders:
city={preg_match 1}/directory\/([a-zA-Z-]+)\/{/preg_match}
cat={preg_match 1}/${city}/([a-zA-Z-]+)/{/preg_match}
subcat={preg_match 1}/${cat}/([a-zA-Z-]+)/{/preg_match}
Last edit: 4 months 4 hours ago by donald.

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

More
3 months 3 weeks ago #6875 by admin
Replied by admin on topic Complex Redirect Rule
Hi Donald,
try the following:
From  URL: ^/directory/.*/all$
ToURL: {scheme}://{siteurl}/directory/${city}/${cat}/${subcat}/all\?cf43[0]=${city}
Request only: true (checked)
Macros:
city={preg_match 1}/\/directory\/([^\/]+)\/([^\/]+)\/([^\/]+)\/all$/{/preg_match}
cat={preg_match 2}/\/directory\/([^\/]+)\/([^\/]+)\/([^\/]+)\/all$/{/preg_match}
subcat={preg_match 3}/\/directory\/([^\/]+)\/([^\/]+)\/([^\/]+)\/all$/{/preg_match}

Kind regards,
Luigi

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

More
3 months 3 weeks ago #6876 by admin
Replied by admin on topic Complex Redirect Rule
BTW,
some macros like preg_match areonly available in the Enteprise version, so if you are using the free Community version this rule will not work.

Kind regards,
Luigi

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

  • donald
  • Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
More
3 months 3 weeks ago - 3 months 3 weeks ago #6882 by donald
Replied by donald on topic Complex Redirect Rule
Yes, I realize this is for Enterprise version, and I just purchased it to try this rule out.

I wasn't sure what other rule may work for my case. Do you know of any other rule that would work?
Last edit: 3 months 3 weeks ago by donald.

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

Time to create page: 0.220 seconds