使用上面目录中的index.php但具有不同的包含

Here's my plan for translating the website, could be absolutely wrong so do correct me:

.htaccess redirect -> x.com/y -> /y/index.php

Now, x.com/index.php has all of the files needed to render the tables from mysql and translation included.

x.com/index.php sample

<body>
<?php include_once("analyticstracking.php") ?><?php include_once("lang.php") ?>
    <!-- Header -->     

                                    <a href="#fourth" class="button scrolly"><?php echo lang('f');?> </a>
                                    <a href="#fifth" class="button scrolly"><?php echo lang('g');?></a>

<!-- First -->
            <section id="first" class="main">
                <header>
                    <div class="container">
                        <h2><img src="images/m9.png"></h2>
                        <p><?php echo lang('m'); echo lang('ba'); ?><br/>.
                            <section><center>
                                <?php include("m9.php") ?>

All of the includes mentioned here are in the x.com directory.


My plan is to do this on each language subdirectory for its index.php:

<body>
<--? get language file from language sub --> <?php include_once("lang.php") ?>
<--? get php from home --> <?php require ("../index.php") ?>
</body?>

So I only have to change 1 index.php file each time I need to change everything.


Is this at all a possibility?

This is my .htaccess if that matters:

RewriteEngine On

RewriteCond %{HTTP:Accept-Language} ^en [NC]
RewriteRule ^$ http://xcsgo.com/en[L,R=301]

RewriteCond %{HTTP:Accept-Language} ^de [NC]
RewriteRule ^$ http://xcsgo.com/de [L,R=301]

RewriteCond %{HTTP:Accept-Language} ^fi [NC]
RewriteRule ^$ http://xcsgo.com/fi [L,R=301]

RewriteCond %{HTTP:Accept-Language} ^fr [NC]
RewriteRule ^$ http://xcsgo.com/fr [L,R=301]

RewriteCond %{HTTP:Accept-Language} ^sw [NC]
RewriteRule ^$ http://xcsgo.com/sw[L,R=301]

RewriteRule ^$ http://xcsgo.com/en [L,R=301]

The Php error I get:

 PHP Fatal error:  require(): Failed opening required 'http://x.comm/index2.php' (include_path='.:/usr/lib/php:/usr/local/lib/php:/usr/local/php54/lib/php') in /home/x/public_html/y/en/index.php on line 30

Changed the x.com/en php code to this:

<?php require("/home/y/public_html/x/index2.php") ;?>
<?php include_once("lang.php") ?>

and this is the error:

PHP Fatal error:  require(): Failed opening required '/home/y/public_html/x/index2.php' (include_path='.:/usr/lib/php:/usr/local/lib/php:/usr/local/php54/lib/php') in /home/y/public_html/x/en/index.php on line 30

You should create a configuration file in the main domain address and set it's name config.php or as you wish then put all default setting into it like this example:

  /*DataBase Configuration!*/
 define("DB_HOST","localhost");
 define("DB_USER", "root");
 define("DB_PASSWORD","root");
 define("DB_PREFIX", "prefix_");
 define("DB_NAME", "db_name");


 /*Directories Configuration!*/
define('DIR_ENGINE', 'C:/xampp/htdocs/main_directories/engine/');
define('DIR_CP', 'C:/xampp/htdocs/main_directories/hyperCP/');
define('DIR_MAIN', 'C:/xampp/htdocs/main_directories/');
define('DIR_LANGUAGE', 'C:/xampp/htdocs/main_directories/languages/');
define('DIR_TEMPLATE', 'C:/xampp/htdocs/main_directories/themes/');
define('DIR_IMAGE', 'C:/xampp/htdocs/main_directories/images/');
define('DIR_UPLOAD', 'C:/xampp/htdocs/main_directories/upload/');

/*SYSTEM CONTROL */
define("ERROR_ACTIVE",1);
define("TEST_MODE",false);
define("MAIN_LANG","ar");
define('TEMPLATE_ACTIVE', 'default');

and this setting you should setup it in the installation progress , after that in all your Application files you must include it !. To define what is the language you should get you can use session for that , when user register he select favorite language and you save it in database after that when he login you take it from the database and save it in the session then apply something like this:

        if(
          isset($_SEESION['lang']) &&
          $_SEESION['lang'] =='ar' ||
          $_SEESION['lang']==1){

         get_lang($_SEESION['lang']); 
         }else{
          get_lang(DEFAULT_LANG); 
         }