Skip Navigation
Updated
March 8, 2022

If WPML doesn’t let you choose language directories (e.g. http://example.com/es/ for Spanish), it’s because it tried accessing that URL and got an error. Here is what you can check to ensure language directories work.

Here is what you need to set up in order for language directories to work:

  1. Enable URL rewriting.
  2. Allow WordPress to have read and write access to folders.
  3. Make sure your site uses a “pretty” permalink structure.

As you can see, there is no need to create physical directories on the server. Choosing to have languages in directories is possible through rewriting the URL.

How WPML determines if it can enable languages in directories

WPML tries to access a test call that checks if languages in directories will work. This test call is:

yourdomain/LANGUAGE/?____icl_validate_domain=1

For example, to check if Spanish is enabled for our own domain (wpml.org), we would go to the following URL in our browser:

http://wpml.org/es/?____icl_validate_domain=1

When you do this, you get a blank looking page. Right-click the page and select View Page Source. You should see the following content:

<!--http://wpml.org-->

This tells WPML that WordPress allows accessing this URL structure. If the call passes, WPML will allow using languages per directories. Otherwise, you’ll get some sort of message which (kind of) explains what the problem is.

If WPML sees an error page it disables this feature and prints out that red error message, with possible explanations for why it’s disabled.

Important: WPML accesses the validation URL by doing an fopen call to it. Normally, it’s similar to what browsers do, but not the same. Make sure that fopen is enabled on your server. You can add the following to your PHP configuration file to make sure that it’s not blocked:

SecFilterEngine Off

Make Sure WordPress Enables URL Rewriting

In order to enable URL rewrite, WordPress creates a file called .htaccess in the folder where it’s installed. WordPress creates this file if you’re using anything other than default URLs. That file should contain the following:

# BEGIN WordPress
<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /index.php [L]
</IfModule>
# END WordPress

If it doesn’t exist, try creating it. If it exists but is empty, copy these contents and save.

What Does Being Able to Rewrite URLs Mean?

URL rewriting is a complex mechanism, used intensively by WordPress. For this to work, the webserver (normally, Apache) needs to be able to rewrite URLs, and WordPress must be allowed to manage the rewrite logic.

In Apache, mod-rewrite does URL rewriting. It’s a pretty standard module that is enabled by default. If you’re using Apache and cannot activate language directories, check that mod-rewrite is active for your site. If you’re not sure how, send an email to your hosting provider. You can use this:

Hey there!

A WordPress plugin that I want to use requires the mod-rewrite module enabled. Can you please check for me and tell me if mod-rewrite is enabled for my website? http://example.com

Assuming it’s enabled, WordPress now needs to be able to control the URL write rules. For this to happen, WordPress must be able to write to the folder in which it’s installed.

Make Sure WordPress Has Read and Write Access to Folders

Again, if you’re using Apache, find out under which user Apache runs and allow that user the read and write access to the folder where WordPress is installed. You can do that using your FTP program, via shell or via email.

Hello again,

I need another favor. I’ve installed WordPress in this directory:

YOUR_WP_INSTALL_DIRECTORY

Can you change the file permissions for the entire directory (recursively), so that the webserver can both read and write there? I need WordPress to be able to write to some of the files.

Now, check again.

Your site needs to use a “pretty” permalink structure. You can change your site’s permalink structure in your WordPress settings.

Troubleshooting

If you use a CDN, such as Cloudflare, it may block languages in directories from working correctly by removing HTML comments. As a result, you may see a false-positive error, which shows a warning related to ?____icl_validate_domain=1 without any issues on the front-end.

Need Help?

If this still doesn’t work, please visit our support forum and open a new issue.