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 1 reply, has 2 voices.

Last updated by Bruno 11 months, 1 week ago.

Assigned support staff: Bruno.

Author Posts
June 21, 2019 at 10:10 am #4066165


I got my site with 2 languages. English which is the default and Dutch witch is the second.
When you go to the website you will land on the default language, but I want it to go to the secondary language once visiting.
I don’t want to use the function of redirect users based on browser language or change the default language.

Now I did find this on the forum, but I’m not sure if it’s the right thing to use and I cant seem to work it out or make it work the right way. (it’s the root file way)

1) Visit WPML>>Languages>>Language URL format
2) Choose *Use directory for default language* option
3) Choose *HTML file* option
4) Create a new PHP file *root-page.php* and place it in *Root folder* of the site
5) Add the following code in *root-page.php* file and save the changes


header('Location: <u>hidden link</u>');


6) Add *root-page.php* as the value for *HTML file* field
7) Save the settings

Once I do that I do get either /en or /nl behind my website url which is fine, but I cant make it to work to go to the /nl directory instead of the /en directory by default. I’m hoping some one understands my question and can help me out.
It also shows this after doing the step described above:

An attempt to open the URL specified as a root page failed with the following error:
404: Not Found

Thanks in advance!

June 21, 2019 at 5:09 pm #4068645


Languages: English (English ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

Thank you for contacting us. Inside the code you're using in "root-page.php", are you using the secondary language URL? For example:

header('Location: <em><u>hidden link</u></em>');

If so, have you ever tried clearing your browser's cache to see how the script is going to behave?

Thank you.

The topic ‘[Closed] need my page to redirect to second language and not default language’ is closed to new replies.