Normally I use the .htaccess to redirect a url like this.
To redirect the multilingual URLs to your main domain using .htaccess, you can set up rewrite rules that redirect any requests for the specific language subdirectories to your main domain. Here’s a basic guide on how you can achieve this:
Access Your .htaccess File: The .htaccess file is usually located in the root directory of your WordPress website. You’ll need to access it via FTP or through your hosting file manager.
Back Up .htaccess File: Before making any changes, it’s crucial to back up your existing .htaccess file. This allows you to restore the original settings in case something goes wrong.
Edit .htaccess File: Open the .htaccess file in a text editor.
Add Redirection Rules: You’ll need to add rules that specifically redirect URLs from the language subdirectories to your main domain. Below is a sample rule for redirecting Japanese (/ja) URLs:
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/ja/(.*)$
RewriteRule ^ja/(.*)$ https://example.com/$1 [R=301,L]
In this rule:
RewriteEngine On ensures that the rewrite engine is enabled.
RewriteCond %{REQUEST_URI} ^/ja/(.)$ checks if the requested URL is in the Japanese subdirectory.
RewriteRule ^ja/(.)$ https://example.com/$1 [R=301,L] redirects the URL to the main domain. R=301 signifies a permanent redirect, and L means this is the last rule to be applied if this condition matches.
Repeat for Other Languages: If you had other languages, repeat the process by replacing /ja/ with the respective language code in the rewrite condition and rule.
Save and Upload .htaccess File: After adding the necessary rules, save your .htaccess file and upload it back to the server.
Test the Redirection: Visit the URLs of the different language subdirectories to ensure that they are properly redirected to your main domain.
Please note:
Replace example.com with your actual domain name.
Ensure that the syntax is correct and there are no typographical errors in the .htaccess file, as even a small mistake can make your website inaccessible.
The redirection might take some time to propagate. If it doesn’t work immediately, clear your browser cache and try again.