Complex Redirect Rule - dynamic trim or preg_match
-
donald
-
Topic Author
-
Offline
-
New Member
-
Less
More
-
Posts: 12
-
Thank you received: 0
-
-
6 years 1 month ago #6886
by donald
I have 100s of URLs that end with /page<number>
example:
/directory/ottawa/food/restaurants-catering/all/page2
/directory/ottawa/food/restaurants-catering/all/page3
/directory/ottawa/food/restaurants-catering/all/page4
/directory/ottawa/food/restaurants-catering/all/page183
I would like to be able to do things:
1) how can I use pathrtrim to trim the /page and number that follows it? I tried, but seems like it goes in an infinite redirect rule and cause a too many redirect error on browser.
2) If I want to preg_match the last part of the URL, how do I go about doing that?
I tried from URL: ^/directory/.*/all/page.*
and placeholder: page={preg_match 4}/\/directory\/([^\/]+)\/([^\/]+)\/([^\/]+)\/all\/([^\/]+)/{/preg_match} with no luck. I can't seem to match the URL.
Your help is appreciated. Thanks.
Please Log in or Create an account to join the conversation.
Less
More
-
Posts: 3194
-
Thank you received: 441
-
-
6 years 1 month ago - 6 years 1 month ago #6892
by admin
Hi Donald,
the first point will not work becaue path macros work on path,i.e. the whole string included in a /../, and not part of it.
You can do omething with the second approach. You could create a
placeholder with the page number and reuse it in your rule as you prefer:
page={preg_match 1}/\/directory\/.*\/page([0-9]+)$/{preg_match}
To put the placeholder in your rule:
Kind regards
Luigi
Last edit: 6 years 1 month ago by admin.
Please Log in or Create an account to join the conversation.
Time to create page: 0.147 seconds