• Resolved DrLightman

    (@drlightman)


    With this setup:

    Source url: ^/foo.html
    Target url: /

    This url /foo.html?bar=baz redirects to /?bar=baz
    I’d like it to redirect here: /

    Changing Target url to /? as I used doing in .htaccess to force an empty query string is no go.

    Redirect’s options does not contemplate query params options when in regexp mode.

    Am I missing anything?

    Thank you.

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author John Godley

    (@johnny5)

    Why do you need to use an expression? If you just want to redirect /foo.html then you can use that as the source URL and enable the ‘ignore query param’ option.

    Thread Starter DrLightman

    (@drlightman)

    Because that is just an example for you to make it more readable, the real cases are more complex.

    • This reply was modified 3 months, 1 week ago by DrLightman.
    Plugin Author John Godley

    (@johnny5)

    Ok, it’s probably better to give a real example. Any expression you create needs to match the whole URL, including parameters.

    Thread Starter DrLightman

    (@drlightman)

    There seems to be a more generic issue not strictly related to the query string with the regexp target url. Test example to reproduce:

    Source url:?^/blabla/
    Target url:?/
    (ignore case ON, ignore slash ON, Regex ON)

    Visited example url: /blabla/images/tree.jpg

    Redirect goes to: /images/tree.jpg

    Expected redirect result: /

    • This reply was modified 3 months, 1 week ago by DrLightman.
    Plugin Author John Godley

    (@johnny5)

    Sure, the expression needs to match the whole URL, not part of it.

    Thread Starter DrLightman

    (@drlightman)

    Mmm ok with that in mind I’m also able to fix the query string discard behaviour.

    Source url:?^/foo.html.*$ or ^/foo.html.*
    Target url:?/

    This works as expected, target url is not contaminated with unwanted strings.

    • This reply was modified 3 months, 1 week ago by DrLightman.

    I’m having problems with this too. I want to redirect anything that goes to <website>/shop/* and send it to a holding page, but by default, it is placing the bit on the end, on the end of the new page.

    I.e. loading <website>/shop/nice-book-stand,
    I want it to go to <website>/shop-is-closed

    but it always goes to <website>/shop-is-closed/nice-book-stand which is a 404.

    How do I discard the bit after the match?

    ——-

    Ah, just worked it out. If set it to regexp and do this:

    <website>/shop/(.*)

    but don’t use $1 in the target, it’s not appended by default.

    • This reply was modified 3 months, 1 week ago by delanthear.
    Plugin Author John Godley

    (@johnny5)

    As above, your expression needs to match the full URL, not just part of it.

    You should look to add an option make this possibly without needing people to select the regexp option. Having it discarded the url after the match is really handy for holding pages etc if you need to turn part of your site off (like a shop where you have lots of deep links into categories).

    Plugin Author John Godley

    (@johnny5)

    Well that’s why the regex option exists, so people can create redirects for any kind of situation.

    Thread Starter DrLightman

    (@drlightman)

    @delanthear

    You are free to omit the parenthesis, if you plan not using the matched string inside them with $:

    /shop/.*

    Or you can tell the parenthesis to not doing so with ?::

    /shop/(?:.*)

    And you can specifically tell to “lock” the regexp to the start and end of the url to match, with ^ and $ at the beginning and ending:

    ^/shop/.*$

    Anyway this is basic regexp functionality, not specific to the Redirection plugin.

    • This reply was modified 3 months, 1 week ago by DrLightman.
    • This reply was modified 3 months, 1 week ago by DrLightman.
Viewing 11 replies - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.