Skip Navigation

Resolved

Overview of the issue

When you are changing the URL format after your posts are published and translated you might have an issue with the URLs redirecting if you directly type them in the browser’s address bar.

For example:

  • You are using Different languages in directories with WPML and your site has a page URL such as http://mysite.com/es/pagina-de-muestra/
  • Now change your URL format to A different domain per language, the above URL is now http://misitio.es/pagina-de-muestra/
  • Open directly http://mysite.com/es/pagina-de-muestra/

The result is a 404 server notice.

* Note – WPML Sticky Links plugin prevent a similar but not the same situation – but in this case, since you are directly using the URL it won’t help

Workaround

This is not a bug but there is a custom way to fix it by modifying the site’s .htaccess file. We can not help you with that since it depends on your setting and it’s advanced custom work but we can provide you an example.

For the previous scenario, you should place a similar code  just above WordPress rules. Right at the top of .htaccess will be fine:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^mysite.com [NC]
RewriteRule ^es(.*)$ http://misitio.es$1 [L,R=301]

All requests to http://mysite.com/es/pagina-de-muestra/ will end up in http://misitio.es/pagina-de-muestra/ now.

Please, keep in mind that:

  • This only works on Apache with mod-rewrite enabled
  • There are numerous resources about this, for example, this blog.

For now, it’s important that you will know that the expected behavior for when you change the URL format is that if you try to access the old domain directly (via the address bar) you will get a 301 redirect to the main default language