I have a bilingual website with English is at domain.com/en/ and Italian at domain.com/it/
If someone visits domain.com they are initially redirected to domain.com/en/ using a PHP header() function.
I’m now wondering if this is the most effective way of achieving this.
I know I can use:
RewriteRule ^$ /en/ [L]
in my .htaccess file to map the home page to the /en/ directory, but if I then try to navigate to (say) about.php I end up at domain.com/about.php which gives me a 404 error. I’m pretty crap with RewriteRules and don’t want to make /it/ inaccessible.
I would prefer you write a very small .php or JavaScript file which takes the client language and moves to the required language instead of always directing to English.
I haven’t used that method for language, but my gut tells me that if I did, I would write the url for about.php correctly as example.com/it/about.php in my navigation (i.e. by checking the current language while displaying the nav items) rather than trying to fix it when the page comes in.