Forum Archive - AJAX requests sent to wrong (with language code) URL

AJAX requests sent to wrong (with language code) URL
Sep 27, 2018 10:16 am by atriaforever
I have successfully installed GTranslate on a WP multisite install hosted on https://trials.knowledgeplaces.com" rel="nofollow" target="_blank, configured as directory install. I have also choosen "directory install" for GTranslate and everything works as expected, except for AJAX requests I send from functions in a child theme. They all fail if I navigate on a translated version of the site. For instance, I have a page at https://trials.knowledgeplaces.com/trai ... turopathie" rel="nofollow" target="_blank. This page sends AJAX requests to https://trials.knowledgeplaces.com/trai ... n-ajax.php" rel="nofollow" target="_blank As long as I stay with the default language, it works fine, all AJAX requests are correctly sent and processed. If I switch to a language such as english, AJAX requests are sent to https://trials.knowledgeplaces.com/en/t ... n-ajax.php" rel="nofollow" target="_blank, and they all fail with a 404 error. Please explain how to proceed so AJAX requests work with any language.
Re: AJAX requests sent to wrong (with language code) URL
Sep 27, 2018 10:49 am by Edvard
Hi, It means that gtranslate rewrite rules are not correctly added into your .htaccess file. Make sure to open GTranslate settings page, then hit save, it should display with red color which should be added into .htaccess file. If it doesn't display anything, make sure to open your .htaccess file and move gtranslate rewrite rules to the top of the file. You can contact our Live chat for more help. https://gtranslate.io/#contact" rel="nofollow" target="_blank Thanks! :)
Re: AJAX requests sent to wrong (with language code) URL
Sep 27, 2018 6:48 pm by atriaforever
I run this WP on a Win Server 2012 with IIS as web server, not Apache. IIS uses its own format to manage rewrite rules. I have logged in to my server and I have seen that your plugin has generated a .htaccess file which contains multiple rewrite rules. They are all written using the Apache .htaccess format. In IIS, there is a utility to import a .htaccess file and convert them to IIS rules. I run the utility but I have an error message on the first rule (see attached screen copy). RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] All other rules have been converted successfully. Despite the error on the first rule, everything seems to work fine now. Thanks for pointing me in the right direction. Last thing: what is the purpose of the first rule? Do I need it on IIS?
Re: AJAX requests sent to wrong (with language code) URL
Sep 28, 2018 6:43 am by Yana
Hi, For IIS web servers use web.config files rules for sub-directory URL structure. IIS rules: <?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <rules> <rule name="gtranslate 1L" stopProcessing="true"> <match url="^(af|sq|am|ar|hy|az|eu|be|bn|bs|bg|ca|ceb|ny|zh-CN|zh-TW|co|hr|cs|da|nl|en|eo|et|tl|fi|fr|fy|gl|ka|de|el|gu|ht|ha|haw|iw|hi|hmn|hu|is|ig|id|ga|it|ja|jw|kn|kk|km|ko|ku|ky|lo|la|lv|lt|lb|mk|mg|ms|ml|mt|mi|mr|mn|my|ne|no|ps|fa|pl|pt|pa|ro|ru|sm|gd|sr|st|sn|sd|si|sk|sl|so|es|su|sw|sv|tg|ta|te|th|tr|uk|ur|uz|vi|cy|xh|yi|yo|zu)/(af|sq|am|ar|hy|az|eu|be|bn|bs|bg|ca|ceb|ny|zh-CN|zh-TW|co|hr|cs|da|nl|en|eo|et|tl|fi|fr|fy|gl|ka|de|el|gu|ht|ha|haw|iw|hi|hmn|hu|is|ig|id|ga|it|ja|jw|kn|kk|km|ko|ku|ky|lo|la|lv|lt|lb|mk|mg|ms|ml|mt|mi|mr|mn|my|ne|no|ps|fa|pl|pt|pa|ro|ru|sm|gd|sr|st|sn|sd|si|sk|sl|so|es|su|sw|sv|tg|ta|te|th|tr|uk|ur|uz|vi|cy|xh|yi|yo|zu)/(.*)$" /> <action type="Rewrite" url="/{R:1}/{R:3}" /> </rule> <rule name="gtranslate 2L" stopProcessing="true"> <match url="^(af|sq|am|ar|hy|az|eu|be|bn|bs|bg|ca|ceb|ny|zh-CN|zh-TW|co|hr|cs|da|nl|en|eo|et|tl|fi|fr|fy|gl|ka|de|el|gu|ht|ha|haw|iw|hi|hmn|hu|is|ig|id|ga|it|ja|jw|kn|kk|km|ko|ku|ky|lo|la|lv|lt|lb|mk|mg|ms|ml|mt|mi|mr|mn|my|ne|no|ps|fa|pl|pt|pa|ro|ru|sm|gd|sr|st|sn|sd|si|sk|sl|so|es|su|sw|sv|tg|ta|te|th|tr|uk|ur|uz|vi|cy|xh|yi|yo|zu)/(.*)$" /> <action type="Rewrite" url="/wp-content/plugins/gtranslate/url_addon/gtranslate.php?glang={R:1}&amp;gurl={R:2}" appendQueryString="true" /> </rule> <rule name="gtranslate 3L" stopProcessing="true"> <match url="^(af|sq|am|ar|hy|az|eu|be|bn|bs|bg|ca|ceb|ny|zh-CN|zh-TW|co|hr|cs|da|nl|en|eo|et|tl|fi|fr|fy|gl|ka|de|el|gu|ht|ha|haw|iw|hi|hmn|hu|is|ig|id|ga|it|ja|jw|kn|kk|km|ko|ku|ky|lo|la|lv|lt|lb|mk|mg|ms|ml|mt|mi|mr|mn|my|ne|no|ps|fa|pl|pt|pa|ro|ru|sm|gd|sr|st|sn|sd|si|sk|sl|so|es|su|sw|sv|tg|ta|te|th|tr|uk|ur|uz|vi|cy|xh|yi|yo|zu)$" /> <action type="Rewrite" url="/{R:1}/" /> </rule> <rule name="wordpress" patternSyntax="Wildcard"> <match url="*"/> <conditions> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/> </conditions> <action type="Rewrite" url="index.php"/> </rule> </rules> </rewrite> </system.webServer> </configuration>

SIMILAR TOPICS

Feature requestsAug 23, 2013 8:51 amReplies: 40Post by: Edvard
Large numbers of crawl errors with double language codeJan 24, 2019 1:43 amReplies: 1Post by: natastna2
Translate website to any specific language, on page loadJan 19, 2019 6:49 amReplies: 1Post by: Leaon7756
Graphic translation for every language is missingDec 19, 2018 7:54 amReplies: 1Post by: Daryl Dixon
How to remove mobile Language Select Button transparencyDec 5, 2018 10:06 pmReplies: 10Post by: JeffTR

Try GTranslate with a free 15 day trial