I have the following scenario. I have a wordpress site running. The site has the following urls:
www.example.com
www.example.com/siteA
www.example.com/siteB
www.example.com/de
www.example.com/de/siteA
www.example.com/de/siteB
My wordpress site has a language switcher, which creates a cookie, when a language is set.
I want to achieve the following. When a user visits the site www.example.com
for the first time the server will get the request for www.example.com
the server should then send a minimal code (not the default index page) that checks the cookie and the browser language preferences. If the cookie is set take the language value from there. If not, take the language value from the browser setting. Send a request to the server and request the page that fits best for the user.
For example, if the language value is set to de
request the page www.example.com/de
.
I want to prevent that I have to load the entire index page two times. First in the default language, English, and after that in the specific language, German. Therefore I need a way to add only minimal code in the first request response.
How can I redirect an Index Page Request before the Default Page has been loaded?