Navigation überspringen

Dieses Thema ist gelöst. Hier finden Sie eine Beschreibung des Problems und der Lösung.

Problem:
You are using WPML to translate your site into multiple languages and have set up different domains for each language. However, images are not displaying correctly on the translated sites.
Solution:
The issue likely stems from CORS (Cross-Origin Resource Sharing) restrictions. To resolve this, you need to configure your server to allow requests from your other domains. Here are the steps depending on your server type:

For Apache servers:

<ifmodule mod_headers.c>
  Header set Access-Control-Allow-Origin "https://dentist-kramer.ch https://dentiste-kramer.ch"
</ifmodule>

For Nginx servers:

location / {
    add_header 'Access-Control-Allow-Origin' 'https://dentist-kramer.ch https://dentiste-kramer.ch';
}

If you are using a CDN or managed hosting, adjust the CORS settings in the control panel to allow requests from both `dentist-kramer.ch` and `dentiste-kramer.ch`. If you are unsure how to modify these settings, we recommend contacting your hosting support for assistance.

Please note that this solution might be outdated or not applicable to your specific case. We highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If the issue persists, please open a new support ticket.

Dies ist das technische Support-Forum für WPML – das mehrsprachige WordPress-Plugin.

Mitlesen können alle, doch nur WPML-Kunden können hier Fragen veröffentlichen. Das WPML-Team antwortet im Forum an 6 Tagen pro Woche, 22 Stunden am Tag.

Schlagwörter: 

Dieses Thema enthält 6 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von Bruno Kos Vor 9 Monaten, 2 Wochen.

Assistiert von: Bruno Kos.

Autor Beiträge
September 10, 2024 um 9:14 pm #16163736

benjaminK-28

Background of the issue:
I am using WPML to translate my site into multiple languages. The origin site is zahnarzt-kramer.ch (DE), and it is translated to dentist-kramer.ch (EN) and dentiste-kramer.ch (FR). I am following the documentation on using different domains per language.

Symptoms:
The images are not shown correctly on the translated sites on the domain.

Questions:
Why are the images not shown correctly on the translated sites?

September 11, 2024 um 5:17 am #16164172

Bruno Kos
WPML-Unterstützer seit 12/2018

Sprachen: Englisch (English ) Deutsch (Deutsch ) Französisch (Français )

Zeitzone: Europe/Zagreb (GMT+02:00)

Hi,

Thank you for contacting WPML support!

I believe the issue is with CORS. CORS is a security feature implemented by web browsers to prevent web pages from making requests to a different domain than the one that served the web page, unless that different domain explicitly allows such requests.

To fix this issue, you need to ensure that the server hosting the fonts (or any other cross-origin resources like images) allows requests from the other domains.

If you have access to the server (Apache or Nginx):

**Apache:**

<IfModule mod_headers.c>
  Header set Access-Control-Allow-Origin "<em><u>versteckter Link</u></em> <em><u>versteckter Link</u></em>"
</IfModule>

**Nginx:**

location / {
    add_header 'Access-Control-Allow-Origin' '<em><u>versteckter Link</u></em> <em><u>versteckter Link</u></em>';
}

If you are using a Content Delivery Network (CDN) or a managed hosting service, look for CORS settings in the control panel and allow requests from both `dentist-kramer.ch` and `dentiste-kramer.ch`.

You need to do this for all domains. I suggest you ask the hosting support about this if unsure how to get there.

Regards,
Bruno Kos

cors.png
September 11, 2024 um 8:49 am #16165189

benjaminK-28

I have added this but it shows now :
The 'Access-Control-Allow-Origin' header contains multiple values '

September 11, 2024 um 9:18 am #16165388

benjaminK-28

' from origin 'versteckter Link' has been blocked by CORS policy: The 'Access-Control-Allow-Origin' header contains multiple values 'versteckter Link, versteckter Link', but only one is allowed.

September 11, 2024 um 9:23 am #16165425

Bruno Kos
WPML-Unterstützer seit 12/2018

Sprachen: Englisch (English ) Deutsch (Deutsch ) Französisch (Français )

Zeitzone: Europe/Zagreb (GMT+02:00)

I see, perhaps you can try with:

<IfModule mod_headers.c>
  SetEnvIf Origin "^<em><u>versteckter Link</u></em>|dentiste-kramer.ch)$" ORIGIN=$0
  Header set Access-Control-Allow-Origin "%{ORIGIN}e" env=ORIGIN
</IfModule>

But note that this is outside of WPML support as this is server thing.

Can you check with your hosting support about this?

September 11, 2024 um 2:52 pm #16167090

benjaminK-28

Looks better, but I get now a different error:
' from origin 'versteckter Link' has been blocked by CORS policy: The 'Access-Control-Allow-Origin' header has a value 'versteckter Link' that is not equal to the supplied origin.

Any idea?
Best regards

September 12, 2024 um 5:13 am #16168692

Bruno Kos
WPML-Unterstützer seit 12/2018

Sprachen: Englisch (English ) Deutsch (Deutsch ) Französisch (Français )

Zeitzone: Europe/Zagreb (GMT+02:00)

I still see the same on both domains so it wasn't activated.

still the same.png