dp926460 2015-07-09 23:08
浏览 19

使用上面目录中的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
  • 写回答

1条回答 默认 最新

  • doupian9490 2015-07-09 23:27
    关注

    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); 
             }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 yolov8边框坐标
  • ¥15 matlab中使用gurobi时报错
  • ¥15 WPF 大屏看板表格背景图片设置
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真