Different languages in subdirectories

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
Rolf
New php-forum User
New php-forum User
Posts: 1
Joined: Mon Apr 05, 2021 2:05 am

Mon Apr 05, 2021 2:22 am

Hi
I'm trying to make my site run in several different languages.
I set $_SESSION['lang'] for the selected language and this works fine.

For SEO optimization I would like each language to be shown in a subdirectory.
FX.
English in mysite.com
German in mysite.com/de
Danish in mysite.com/da
etc.

Still I would like all the code and folder to stay in the root so that I only need to update the code in one place.

Is there a way in PHP to do that?

Thanks! :D
User avatar
hyper
php-forum GURU
php-forum GURU
Posts: 1222
Joined: Mon Feb 22, 2016 5:52 pm

Thu Apr 08, 2021 11:45 am

The simplest way to do this is to use the HTML lang tag, there is probably little SEO value in doing anything else, search engines use the lang tag in the document header.

Code: Select all

<!DOCTYPE html>
<html lang="en">
It is possible to use directory strucure if you really want to, but, that can be a lot of work depending on your knowledge.
Post Reply