How to Redirect a Website Based on Browser Language – WordPress
If you are looking to redirect your website based on the language in which it is being accessed, then you have come to the right place. This article will teach you how to do exactly that with minimal effort using a WordPress plugin called Language Redirect.
Overview of the Language Redirect Plugin
If you are reading this, I assume that you either own or have access to a WordPress site (or are building one). If this is the case, then you can learn more about Language Redirect by visiting the plugin’s home page at https://wordpress.com/plugins/language-redirect/. You will find a link to the plugin’s documentation and support there as well.
Installing and Activating the Plugin
To learn how to redirect a website based on language, you will need to install and activate the Language Redirect plugin on your WordPress site. To do this, navigate to https://wordpress.com/plugins/language-redirect/ and click on the Install button. Once the plugin has been installed, you will need to click on the Activate button to actually use it. This way to activate the plugin, as indicated by the plugin’s documentation:
As soon as you activate it, you will see some sample content in the plugin’s dashboard. You can click on the View Live Site button to see your site live. You should also see a small link at the top right of the page that says “Language Redirect”. Click on this to be redirected to the WordPress documentation for the plugin.
How to Configure the Plugin
Once you have activated the plugin, you will see a tab called Options in the WordPress dashboard. You can click on this tab to access the plugin’s settings page. Here you can configure various aspects of the plugin’s behavior. For example, you can tell the plugin to only redirect languages supported by your site’s code, or you can choose to redirect all requests, except those made from your site’s own domain name.
What Happens When You Enable or Disable the Plugin?
You can learn a lot more about the plugin by reading its documentation, but here’s a quick overview of how the plugin works. If you tell the plugin to redirect all requests, except for those made from your site’s own domain name, then it will only affect the English language versions of your site. Any other language versions (e.g., French, German, etc.) will not be redirected by default (even though they may be supported by your site’s code).
To actually see the effect of the French language being redirected, navigate to any page on your site and enter something in the URL box (e.g., http://yourdomain.com/contact). You will then see something like this in the browser’s address bar:
When you click on the address bar to go to a new page, you will see this:
As you can see, the plugin is only taking effect for the French language version of your site, which happens to be the version that’s currently being requested. To make sure that all language versions of your site are being supported, you will need to go into the settings of the plugin and choose to redirect all requests.
More About the Plugin
If you want to learn more about the plugin’s features, then you can read its documentation, which you will find linked from the plugin’s home page.
In addition to its basic use as explained above, the plugin comes with a bunch of features that you can enable or disable through the settings page. If you tell the plugin to redirect all requests (except for those made from your site’s own domain name), then all the various language versions of your site will be supported and you don’t have to worry about manually choosing which ones to be redirected.
Setting Up Redirects for Mobile
If you run a website that’s mostly accessed through mobile devices (e.g., smartphones), then you will want to learn how to redirect these requests as well.
To do this, go to the plugin’s home page and click on the Get Started button. In the Add New Device field, you will need to specify the model of the mobile device (e.g., Samsung S3, iPhone 6, Blackberry 10, etc.), the browser language, and the country of operation.
After you click on the Update Device Status button, you will see the mobile settings page where you can configure the redirection for different browsers and mobile devices.
Using the Plugin
Once you have installed the plugin and configured it as needed, you can use it to redirect your site’s language based on the browser from which the request is being made. To do this, navigate to http://yourdomain.com/ (no need to add the language code or /contact URL) and you will see the language of your site being displayed in the address bar:
As you can see above, the plugin automatically detects the browser language and redirects the visitor to the correct language version of your site (e.g., English, French, or German). In addition to the language redirection, you can also configure the plugin to automatically open a certain page in a new tab or window when a certain word is found (e.g., the word “contact” will automatically open the contact page in a new window).
As you can see from the above example, the plugin automatically opens the contact page in a new window, so you don’t have to manually visit this page whenever you want to contact the company.
Managing Redirects From One Place
Let’s say that you own or administer multiple websites and you want to keep track of the various redirects from one place (e.g., for maintenance purposes). If you use the plugin as explained above, then all of the redirects will be managed through the settings page.
To learn more, you can click on the Support link at the bottom of the plugin’s documentation.