WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. rtwood
    Member
    Posted 1 year 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.

    http://wordpress.org/extend/plugins/transposh-translation-filter-for-wordpress/

  2. rtwood
    Member
    Posted 1 year ago #

    resolved

  3. Ofer Wald
    Member
    Plugin Author

    Posted 1 year ago #

    Hi,

    Care to share your solution?

    Thanks,

  4. rtwood
    Member
    Posted 1 year 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]
    </IfModule>
  5. Ofer Wald
    Member
    Plugin Author

    Posted 1 year 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

About this Topic

Tags

No tags yet.