• Resolved hendrik86

    (@hendrik86)


    Hi!

    I’m currently relaunching a shop system and have some problems using your plugin to redirect old URLs to new ones.

    Having this kind of product URLs on the old typo3 page:

    /products/detail/?tx_commerce_pi1%5BshowUid%5D=5455&tx_commerce_pi1%5BcatUid%5D=&tx_commerce_pi1%5BbasketHashValue%5D=1b0bfa5f62&cHash=9f290e8ea8c95878f2a18e6e6521d997

    I need to match the
    tx_commerce_pi1[showUid]=5455
    parameter to redirect to something like
    /products/product-title.

    My regex redirect rule looks like this:
    ^(/products/detail/\?tx_commerce_pi1\[showUid\]=5455)(.*?)$

    If I try using the non encoded URL /products/detail/?tx_commerce_pi1[showUid]=5455 it works fine, but using the encoded URL
    /products/detail/?tx_commerce_pi1%5BshowUid%5D=5455
    I get a “too many redirects error”.

    I’ve tried to get more infos using
    curl -L -v "https://staging.xxxxxxxx.de/products/detail/?tx_commerce_pi1%5BshowUid%5D=5455"
    getting this output, but don’t get the error…


    * Trying 46.252.27.XXX...
    * TCP_NODELAY set
    * Connected to staging.xxxxxxxxxxx.de (46.252.27.XXX) port 80 (#0)
    > GET /products/detail/?tx_commerce_pi1%5BshowUid%5D=5455 HTTP/1.1
    > Host: staging.xxxxxxxxxxx.de
    > User-Agent: curl/7.64.1
    > Accept: */*
    >
    < HTTP/1.1 301 Moved Permanently
    < Date: Wed, 09 Sep 2020 11:18:13 GMT
    < Server: Apache/2.4.38 (Debian)
    < Set-Cookie: agp-cookies-allow-thirdparty=0; expires=Fri, 08-Jan-2021 11:18:13 GMT; Max-Age=10454400; path=/
    < Set-Cookie: agp-cookies-allow-statistics=0; expires=Fri, 08-Jan-2021 11:18:13 GMT; Max-Age=10454400; path=/
    < Set-Cookie: agp-cookies-confirmed=0; expires=Fri, 08-Jan-2021 11:18:13 GMT; Max-Age=10454400; path=/
    < Expires: Wed, 09 Sep 2020 12:18:14 GMT
    < Cache-Control: max-age=3600
    < X-Redirect-By: redirection
    < Location: /products/detail/?tx_commerce_pi1%5BshowUid%5D=5455
    < Content-Length: 0
    < Content-Type: text/html; charset=UTF-8
    <
    * Connection #0 to host staging.xxxxxxxxxxx.de left intact
    * Issue another request to this URL: 'https://staging.xxxxxxxxxxx.de/products/detail/?tx_commerce_pi1%5BshowUid%5D=5455'
    * Found bundle for host staging.xxxxxxxxxxx.de: 0x7f8f3cc187e0 [can pipeline]
    * Could pipeline, but not asked to!
    * Re-using existing connection! (#0) with host staging.xxxxxxxxxxx.de
    * Connected to staging.xxxxxxxxxxx.de (46.252.27.XXX) port 80 (#0)
    > GET /products/detail/?tx_commerce_pi1%5BshowUid%5D=5455 HTTP/1.1
    > Host: staging.xxxxxxxxxxx.de
    > User-Agent: curl/7.64.1
    > Accept: */*
    >
    < HTTP/1.1 301 Moved Permanently
    < Date: Wed, 09 Sep 2020 11:18:14 GMT
    < Server: Apache/2.4.38 (Debian)
    < Set-Cookie: agp-cookies-allow-thirdparty=0; expires=Fri, 08-Jan-2021 11:18:14 GMT; Max-Age=10454400; path=/
    < Set-Cookie: agp-cookies-allow-statistics=0; expires=Fri, 08-Jan-2021 11:18:14 GMT; Max-Age=10454400; path=/
    < Set-Cookie: agp-cookies-confirmed=0; expires=Fri, 08-Jan-2021 11:18:14 GMT; Max-Age=10454400; path=/
    < Expires: Wed, 09 Sep 2020 12:18:14 GMT
    < Cache-Control: max-age=3600
    < X-Redirect-By: redirection
    < Location: /products/detail/?tx_commerce_pi1%5BshowUid%5D=5455
    < Content-Length: 0
    < Content-Type: text/html; charset=UTF-8
    <
    * Connection #0 to host staging.xxxxxxxxxxx.de left intact
    * Issue another request to this URL: 'https://staging.xxxxxxxxxxx.de/products/detail/?tx_commerce_pi1%5BshowUid%5D=5455'
    * Found bundle for host staging.xxxxxxxxxxx.de: 0x7f8f3cc187e0 [can pipeline]
    * Could pipeline, but not asked to!
    * Re-using existing connection! (#0) with host staging.xxxxxxxxxxx.de
    * Connected to staging.xxxxxxxxxxx.de (46.252.27.XXX) port 80 (#0)
    > GET /products/detail/?tx_commerce_pi1%5BshowUid%5D=5455 HTTP/1.1
    > Host: staging.xxxxxxxxxxx.de
    > User-Agent: curl/7.64.1
    > Accept: */*
    >
    < HTTP/1.1 301 Moved Permanently
    < Date: Wed, 09 Sep 2020 11:18:14 GMT
    < Server: Apache/2.4.38 (Debian)
    < Set-Cookie: agp-cookies-allow-thirdparty=0; expires=Fri, 08-Jan-2021 11:18:14 GMT; Max-Age=10454400; path=/
    < Set-Cookie: agp-cookies-allow-statistics=0; expires=Fri, 08-Jan-2021 11:18:14 GMT; Max-Age=10454400; path=/
    < Set-Cookie: agp-cookies-confirmed=0; expires=Fri, 08-Jan-2021 11:18:14 GMT; Max-Age=10454400; path=/
    < Expires: Wed, 09 Sep 2020 12:18:14 GMT
    < Cache-Control: max-age=3600
    < X-Redirect-By: redirection
    < Location: /products/detail/?tx_commerce_pi1%5BshowUid%5D=5455
    < Content-Length: 0
    < Content-Type: text/html; charset=UTF-8
    ...

    Looking forward to get any suggestions!

    Cheers
    Hendrik

    • This topic was modified 4 years, 2 months ago by hendrik86.
    • This topic was modified 4 years, 2 months ago by hendrik86.
Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author John Godley

    (@johnny5)

    I’m not sure what the question is – can you explain a bit more?

    Thread Starter hendrik86

    (@hendrik86)

    Hey John,

    thanks for your quick reply!
    It’s quite simple; the plugin doesn’t seem to work for encoded URLs which have special characters like “[” or “]” when you use regex.

    1. Set the following rule:

    Source URL: ^(/test/\?parameters\[key\]=1) (regex option enabled)
    Query Parameters: Exact match…
    Target URL: /any-valid-url

    2. Go to /test/?parameters[key]=1 (should redirect to /any-valid-url, works)

    3. Go to the same, but encoded URL /test/?parameters%5Bkey%5D=1 (does not work, browser sais “too many redirects”)

    Am I missing something? Is the regex wrong for the given example? How can I make the decoded and encoded URLs get to work? Is this clear enough?

    Thanks a lot,
    Hendrik

    • This reply was modified 4 years, 2 months ago by hendrik86.
    Plugin Author John Godley

    (@johnny5)

    I don’t have the full URLs so I can’t really test anything there about the infinite redirect, but if Redirection is powering this then it’s because your redirect is matching itself.

    The URL without encoding and the URL with encoding are different URLs, and if you want to match both cases then your redirects will need to handle both.

    Thread Starter hendrik86

    (@hendrik86)

    “I don’t have the full URLs so I can’t really test anything”

    You can, with a clean wordpress setup it behaves the same.

    “if you want to match both cases then your redirects will need to handle both.”

    That’s not possible, because when you enter an URL like
    /?parameters%5Bkey%5D=1
    as the source URL, the plugin automatically decodes the URL when you save the rule to
    /?parameter[key]=1. So you cannot enter two rules here.

    And basically both URLs are the same, only differently encoded.
    And the plugin already handles both types as one, but not for regex rules.

    • This reply was modified 4 years, 2 months ago by hendrik86.
    • This reply was modified 4 years, 2 months ago by hendrik86.
    • This reply was modified 4 years, 2 months ago by hendrik86.
    • This reply was modified 4 years, 2 months ago by hendrik86.
    • This reply was modified 4 years, 2 months ago by hendrik86.
    Plugin Author John Godley

    (@johnny5)

    The PHP regex function seems to be matching the regular expression when it shouldn’t, but is returning the original URL instead of the target URL. This causes a loop as you are then directed to the same URL.

    I don’t really know why this would be the case, and it’s not something I’ve seen before, but as Redirection uses PHP for regular expressions it just follows along and does what it says.

    I will need to investigate further in a future version, but for the moment I have no real answer.

    Thread Starter hendrik86

    (@hendrik86)

    “I will need to investigate further in a future version, but for the moment I have no real answer.”

    Hey John.
    That’s fine for me.

    I’ve tried to use another regex and it works now.

    ^.*?/products/detail/.*?showUid.{1,3}=3(.*?)$

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Too many redirects using regular expressions on encoded URLs’ is closed to new replies.