A
A
Alex Kizyma2018-03-02 18:12:19
PHP
Alex Kizyma, 2018-03-02 18:12:19

How to put a php check (if) and check the content that is in the root of the site?

I have a site with different languages ​​rus, en, ua
how to check what is after the domain
for example
www.mysite.ru/uk/
www.mysite.ru/en_US/
www.mysite.ru/ru_RU/
to display the content of the corresponding language?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
J
John Doe, 2018-03-02
@rabbit418

<?php
$request_uri = explode('/', $_SERVER['REQUEST_URI'], 2);

switch ($request_uri[0]) {
    case '/uk':
        # code...
        break;

    case '/en_US':
        # code...
        break;

    case '/ru_RU':
        # code...
        break;

    default:
        # code...
        break;
}

M
Maxim, 2018-03-02
Alexsev @MaxGoody

$uri = trim($_SERVER['REQUEST_URI'], '/');
switch($uri) {
  case 'uk':
    # Твой код
    break;
  case 'en_US':
    # Твой код
    break;
  case 'ru_RU':
    # Твой код
    break;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question