• I am trying to remove the query string from my URLs when I redirect them but it is preserving them. I can’t get the regex right.

    Also, I have multiple templates that redirect to different urls so I can’t just use .* after howto.php

    I want /templates/howto.php?page=template-business-plan

    to go to

    /business-plan

    but i keep getting /business-plan?page=template-business-plan

Viewing 5 replies - 1 through 5 (of 5 total)
  • Does this work?
    Sourec: /templates/(.*)
    Target: /business-plan/

    • This reply was modified 8 years, 3 months ago by mostman.

    Hi,
    I’m having a similar issue.
    I recently moved my blog posts URL from mysite.com/post-title to mysite.com/blog/post-title.
    I’ve made all the redirections with the plugin ; it works fine, except when they have some parameters.
    So all the URL with the google tracking parameters (like : utm_content=, utm_source= etc) are not redirected.
    I tried this :
    source : mysite.com/post-title?(.*)
    direction : mysite.com/blog/post-title

    But it does’nt work, it causes a redirection loop (i’m redirected to mysite.com/blog/blog/blog/blog/log/blog/post-title).
    Can you help me with that ? thanks !

    Thread Starter nbeers22

    (@nbeers22)

    It looks like you want to keep the parameters and add them to your redirected URL and I am looking to remove them.

    If you want to keep them and add your analytics tracking to the new url, then do this:

    ^/post-title.*
    /blog/new-post-title

    the ^ means starts with and the .* will take everything after it and add it to the end. You don’t need the parenthesis around the .*

    and make sure to check the regex box

    Thread Starter nbeers22

    (@nbeers22)

    Unfortunately, that still adds the query parameters to the new url

    Great, it works fine, thanks ! With this rule, the redirection works, the parameters are removed, but it’s OK, since what I wanted to avoid is the 404 error.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Remove query string on redirect’ is closed to new replies.