0

I used Polylang plugin to add multilingual system to my website. But I have removed the Polylang and the multilingual system.

I want to redirect these multilingual website to my domain. Instead of example.com/ja, I want to get the website on example.com.

Do you know a way to make this redirection ?

1
  • Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer.
    – Community Bot
    Commented Jan 24 at 16:13

1 Answer 1

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.