Transposh WordPress Translation
[resolved] Redirect /?lang=xx to seo friendly /xx/ format (5 posts)

  1. rtwood
    Posted 3 years ago #

    I have switched my urls from the ?lang=xx to the seo friendly /xx/ format. However, I want to automatically 301 redirect any visitors that go to the old /?lang=xx to the new /xx/ url.

    Canonical is already in the code but I would like the visitors to go to the new seo friendly language page automatically.

    I have searched all over the internet for a ?lang=xx to /xx/ htaccess rule but cannot find it. If you can help me I would greatly appreciate it.

    Thanks in advance.


  2. rtwood
    Posted 3 years ago #


  3. Ofer Wald
    Plugin Author

    Posted 3 years ago #


    Care to share your solution?


  4. rtwood
    Posted 3 years ago #

    Hi Ofer,

    I was able to add code to my htaccess file to get it to work. It may not be the best method, but it works great so far.

    I added this to the very beginning of my .htaccess file. It is important that it is at the top of your htaccess (or before wordpress permalink rewrite code)

    <IfModule mod_rewrite.c>
    RewriteCond %{QUERY_STRING} ^(.*)lang=([a-z]{2})&?(.*)$
    RewriteRule (.*) /%2/$1?%1%3 [R=301,L]
  5. Ofer Wald
    Plugin Author

    Posted 3 years ago #

    Thanks for sharing :)

    You are probably missing the Chinese of Taiwan variant (zh-tw) language in the redirect, but I guess it is not really that important

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Transposh WordPress Translation
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic


No tags yet.