QUESTIONS CENTRECategory: php generalMy wordpress and WPML plugin states an error when clicking on pages
ZENHOST Support Staff asked 9 years ago

You have installed WPML and when browsing the website it brings errors not found?

Not Found

The requested URL /en/ was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use
an ErrorDocument to handle the request.

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 get an error.

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

  1. Enable URL rewriting.
  2. 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 call:

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

    When you make this call, you’ll get a blank looking page. Its content (which you can see by looking at the page’s source) is:

    <!--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 set add the following to your PHP configuration file to make sure that it’s not blocked:

    SecFilterEngine Off

    Make sure that WordPress enables URL rewriting

    In order to enable URL rewrite, WordPress will create a file called .htaccess in the folder where it’s installed. WordPress will create 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.