WPML htaccess Redirect After Switching to Language Directories

Switching WPML from language query parameters to language directories breaks every old URL. This htaccess rule redirects them to the right new path.

By Mark Koemans 1 min read

Silhouette of a signpost with three arms pointing in different directions against a pink and blue sunset sky

This article is also available in German.Read the German version

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 directories?

From this setting, the language name added as a parameter: https://www.example.com?lang=fr for French.

To this setting, a directory per language: https://www.example.com/ for English and https://www.example.com/fr/ for French.

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