Skip to content

Instantly share code, notes, and snippets.

@alewolf
Last active October 30, 2019 09:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alewolf/89b215d4a84b42bb776907b9f9e90a33 to your computer and use it in GitHub Desktop.
Save alewolf/89b215d4a84b42bb776907b9f9e90a33 to your computer and use it in GitHub Desktop.
# BEGIN WPML Redirect
RewriteEngine on
RewriteCond %{QUERY_STRING} lang=(..) [NC]
RewriteCond %{REQUEST_URI} !^/wp-admin [NC]
RewriteRule ^(.*\/)|^$ /%1/$1? [L,R=301]
# END WPML Redirect
@alewolf
Copy link
Author

alewolf commented Sep 6, 2019

You've been using the WPML setting that adds a query parameter at the end of a URL to select the language
and now you want to switch to the setting where the languages are in different directories?

From this setting: Language name added as a parameter (https://www.example.com?lang=fr - French)
To this setting: Different languages in directories ((https://www.example.com/ - English, https://www.example.com/fr/ - French))

Then the above redirect rule is for you. It safely redirects all old URLs to the new ones, after you did the switch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment