This is the technical support forum for WPML - the multilingual WordPress plugin.
Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.
This topic contains 4 replies, has 3 voices.
Last updated by Lucas Vidal de Andrade 3 months ago.
Author | Posts |
---|---|
January 24, 2024 at 12:33 am #15219303 | |
gabrielS-38 |
Tell us what you are trying to do? I need to redirect my production blog urls to the new WPML urls. The urls will be ALMOST the same. the difference is the language code. On My current production site, portuguese is like this: /pt_BR/ while in WPML is like this /pt-br/ example: actual url in portuguese in my live production site: new WPML url in portuguese in my local developing site: I want to use a custom .htaccess rule, to redirect every page that has /pt_BR/ on the url, to the same exact url, but with the /pt-br/ code instead. On my new local development WPML site I am testing this. I created the following post in english (default), and in portuguese as well: english: hidden link Then I typed the portuguese url, but with my production site lang code, just to try if the redirection is working: hidden link and for some reason, I am redirected to the english (default) post url: Why is this? I deleted my .htaccess rule because and redirection to english slug continues. What I would expect: Is there any documentation that you are following? Is there a similar example that we can see? What is the link to your site? |
January 24, 2024 at 7:22 am #15219932 | |
Sumit Supporter
Languages: English (English ) Timezone: Asia/Kolkata (GMT+05:30) |
Hi, Thank you for contacting the support forum. The redirect might be coming from WP, redirecting to the correct post based on a slug. To bypass this you can place your redirect rule on the top of htaccess file before WP rules. Thus it will redirect pt_BR request to pt-br even before passing the request to WP rules. Thanks |
January 24, 2024 at 8:14 am #15220075 | |
gabrielS-38 |
Hi Sumit, thank you for your quick answer. 1. 2. Please, do not respond to email. Thank you. |
January 24, 2024 at 8:18 am #15220083 | |
gabrielS-38 |
By the wat, I don't think there is any rewritte condition on that .htaccess (besides the one that I added). That makes me think that the redirection might me comming from WPML? |
January 24, 2024 at 12:15 pm #15221645 | |
Lucas Vidal de Andrade Supporter
Languages: English (English ) Spanish (Español ) German (Deutsch ) Portuguese (Brazil) (Português ) Timezone: America/Sao_Paulo (GMT-03:00) |
Hi, Thank you for trying out the .htaccess modifications and sharing the detailed information. It's helpful in narrowing down the potential causes. Considering that the .htaccess changes didn't produce the desired result, there are a few additional aspects we can look into: 1. WordPress has its own redirection mechanisms, especially for canonical URLs, which might be overriding your .htaccess rules. This could be the reason why the request is being redirected to the English version of the post. 2. If you have any caching implemented (either via a plugin or server-level), try clearing it. Also, go to the WordPress admin panel, navigate to "Settings" > "Permalinks", and just click "Save Changes" to reset the permalinks. This sometimes resolves unexpected redirection issues. 3. If you're comfortable with PHP, you could add a small snippet at the top of your theme's functions.php file to handle this redirection. This would bypass .htaccess and WordPress's default behavior, ensuring your specific rule is executed first. Check this documentation: Since the site is still in a local development environment, it's a good opportunity to experiment with these suggestions without affecting the live site. Please try these steps and let us know how it goes. We're here to assist you further if needed. Best Regards, |
This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.