Viewing 10 replies - 1 through 10 (of 10 total)
  • It makes sense that it wouldn’t work, if you aren’t using regex to account for the characters at the end.

    https://www.travelnasia.com/blog/map-attractions-bangkok-skytrain/ and https://www.travelnasia.com/blog/map-attractions-bangkok-skytrain/?lang=zh are two different URLs. I know they serve the same function for you, but with different languages, but for the web server, it is two different strings of characters.

    Your best bet is to use regex to account for stuff coming after the last slash, and forwarding it along. One thing to try is the following pattern, with regex turned on:

    Source: https://www.travelnasia.com/blog/map-attractions-bangkok-skytrain/(.*)

    Target: https://www.travelnasia.com/blog/bangkok-skytrain-bts-mrt-lines/$1

    If ?lang=zh (or anything else) is present on the source URL, it will append it to the target URL. ^_^

    Thread Starter qlddrones

    (@websupportguy)

    Thanks Maiki, that worked.

    Groovy! Please mark this as resolved. ^_^

    Thread Starter qlddrones

    (@websupportguy)

    Thanks for the help

    Thread Starter qlddrones

    (@websupportguy)

    Sorry to be re-opening this request, but the resolution provided is now creating a redirection loop.

    I currently have two redirects in place:

    /chiang-mai-tours redirects to https://www.travelnasia.com/blog/chiang-mai-tours

    /chiang-mai-tours/(.*) redirects using regex to https://www.travelnasia.com/blog/chiang-mai-tours/$1

    Neither redirect is currently working. If I understand regex correctly, the auto-stripping of the source URL will causing the /chiang-mai-tours/ in the destination URL to be redirected again, creating an endless loop.

    Can this not be done using the redirection plugin? Or am I missing something?

    Tony

    Thread Starter qlddrones

    (@websupportguy)

    By the way, I deleted the first one and the second still doesn’t work.

    Thread Starter qlddrones

    (@websupportguy)

    I’m not sure what the problem here is. I changed the post URL back to /chiang-mai-tours/ hoping WordPress would automatically redirect it and it does, but not with the ?lang=zh suffix attached.

    I have deleted the old redirections and added a new one:

    /blog/chiang-mai-tours/(*) redirects with regex to /chiang-mai-tours/$1

    But it doesn’t work at all. At least the endless redirection is fixed but that doesn’t help all that much as this page gets a lot of Chinese search visits.

    Weirdly, when I changed the redirection to:

    /blog/chiang-mai-tours/?lang=zh redirects without regex to /zh/chiang-mai-tours/ it now redirects correctly to https://www.travelnasia.com/chiang-mai-tours/?lang=zh

    But that only corrects the problem for lang=zh, not other languages (e. lang=de)

    You’ve given a lot of information here, and it is too much for me to process. Normally to debug this kind of thing, you need to test it out in a development setup, so you can turn on and off plugins, and try different patterns.

    I suggest you create a local/dev WordPress instance, and play around with the patterns you are trying out. That is how I figured out your initial question. That way you can confirm a regex pattern works, and can then apply it to your site. Then, if it doesn’t work, you can start deducing which of the plugins or configuration options is getting in the way.

    Good luck! ^_^

    Thread Starter qlddrones

    (@websupportguy)

    Sorry for confusing you earlier. Let’s try this at a very basic progressive level and see if the issue can be debugged.

    I’ve now created a bare test site (all plugins disabled except Redirection and Transposh, all existing redirects removed, clean HTACCESS).

    To test the problem, I have created a redirection from https://test.travelnasia.com/test-rewrite/ to https://test.travelnasia.com/write-a-review/ which works just fine but fails when “/?lang=zh” is added to the source URL.

    I created another regex redirect as per your instructions from
    https://test.travelnasia.com/test-rewrite/(.*) to https://test.travelnasia.com/write-a-review/$1 and that passed on the lang parameter to the destination URL.

    With that working ok, I created a third test redirect from
    https://test.travelnasia.com/test-rewrite/(.*) to
    https://test.travelnasia.com/destination/bangkok/don-mueang-airport-bangkok/$1 and that also works OK.

    I then created a new regex redirect from
    https://test.travelnasia.com/thailand/bangkok/don-mueang-airport/(.*) to
    https://test.travelnasia.com/destination/bangkok/don-mueang-airport-bangkok/$1 which also works fine.

    But when I create the same redirection in my live site
    https://www.travelnasia.com/thailand/bangkok/don-mueang-airport/(.*) to
    https://www.travelnasia.com/thailand/don-mueang-airport-bangkok/$1 it redirects to the home page, with the language parameter intact.

    I don’t know why it does this because
    https://www.travelnasia.com/test-rewrite/ to https://www.travelnasia.com/thailand/don-mueang-airport-bangkok/$1 works just fine.

    I can only imagine that some other redirection is interfering with it. But I cannot find any redirects that refer to either of these URLs except the two above used for testing.

    When I look in the Redirection log, I can see the call to “test-rewrite” but I cannot see the call to “thailand/bangkok/don-mueang-airport” anywhere, which suggests that the Redirection module is being bypassed on this call? Maybe something else is over-riding it?

    I’ve even tried creating similar redirects in HTACCESS and they also don’t work. I really don’t know where to go from here.

    Thread Starter qlddrones

    (@websupportguy)

    Sorry Maiki, the last problem was of my own making! There was a test redirection to and from the same page still active in HTACCESS. When I deleted that, the full redirection from https://www.travelnasia.com/thailand/bangkok/don-mueang-airport/(.*) to
    https://www.travelnasia.com/thailand/don-mueang-airport-bangkok/$1 started working just fine.

    So now I just need to try that pattern with some of the other URLs that are failing and see if I can fix them too.

    Thanks for your help. I’ll only come back if I hit another wall.

    Regards, Tony

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Redirections fail for "?lang=zh"’ is closed to new replies.