#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2009
    Posts
    106
    Rep Power
    6

    Folders with same language and design but different database query problem


    dear everyone..
    i am developing a website that contains 4 folders (gl,gb,kz,eg) each folder related to different country and all the website data are in English language but the difference is in the MySQL query of database to get data according to the country

    1) www.example.com/gl/ (Global English version)
    2) www.example.com/gb/ (UK version)
    3) www.example.com/kz/ (Kazakh version)
    4) www.example.com/eg/ (Egyptian version)



    i don't want to add my files to the root of each folder to avoid the headache when changing css or anything in the website..

    i dont want to change everything in 4 folders, i want to change only one file and those changes to affect in each folder, i tried to put my files in the root of my project and in each folder i made include to get the data


    for example : in gl:
    PHP Code:


    $select_query1 
    "SELECT * FROM databaseo where page='about' and lango='gl'";
        
    //print "select_query1: " . $select_query1 . "<br>";
        
    $res_query1 mysql_query($select_query1)
        or die (
    "table error1: " mysql_error());
    $res_rows1 mysql_num_rows($res_query1);
    //echo $res_rows1;
    //$tr_res_query1 = mysql_fetch_array($res_query1);

    //or

        
    while ($tr_res_query1 mysql_fetch_array($res_query1))
        {
        echo 
    'result here<br>';
        
        }
    include(
    '../about.php'); 
    and in gb

    PHP Code:
    $select_query1 "SELECT * FROM databaseo where page='about' and lango='gb'";
        
    //print "select_query1: " . $select_query1 . "<br>";
        
    $res_query1 mysql_query($select_query1)
        or die (
    "table error1: " mysql_error());
    $res_rows1 mysql_num_rows($res_query1);
    //echo $res_rows1;
    //$tr_res_query1 = mysql_fetch_array($res_query1);

    //or

        
    while ($tr_res_query1 mysql_fetch_array($res_query1))
        {
        echo 
    'result here<br>';
        
        }
    include(
    '../about.php'); 
    etc..............

    but it did not work for me because of difference in paths for *.js files and for folders.. any idea????
  2. #2
  3. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1014
    Hi,

    you must not use physical language folders at all. I mean, copypasting the same PHP scripts four times just to change two characters is hardly an acceptable solution.

    Read up on URL rewriting. What you want your webserver to do is remove the language part from the path and pass it as a URL parameter instead:

    Code:
    www.example.com/gl/index.php -> www.example.com/index.php?lang=gl
    So you have one PHP script, and it receives the language through the lang parameter. With that information, it can dynamically build the content for this particular language.
    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2009
    Posts
    106
    Rep Power
    6
    Originally Posted by Jacques1

    Read up on URL rewriting. What you want your webserver to do is remove the language part from the path and pass it as a URL parameter instead:

    Code:
    www.example.com/gl/index.php -> www.example.com/index.php?lang=gl
    So you have one PHP script, and it receives the language through the lang parameter. With that information, it can dynamically build the content for this particular language.

    you mean that i can make it using htaccess file?? notice that the client need it to be like folders, not like this
    Code:
    index.php?lang=gl
    he want it to be like
    Code:
    www.example.com/gl/
    i want to know if this will be helpfull for SEO???
    Last edited by john_zakaria; August 1st, 2013 at 04:44 AM.
  6. #4
  7. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1014
    Originally Posted by john_zakaria
    you mean that i can make it using htaccess file??
    Yes.



    Originally Posted by john_zakaria
    notice that the client need it to be like [...] he want it to be like [...]
    That's why I talked about rewriting the URL. You start with a user-friendly URL (with the language as a pseudo-directory), and then you transform it into a machine-friendly URL (with the language as a URL parameter attached to the actual path).



    Originally Posted by john_zakaria
    i want to know if this will be helpfull for SEO???
    Compared to what?
    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2009
    Posts
    106
    Rep Power
    6
    Originally Posted by Jacques1
    Yes.
    i am trying to make this task using htaccess but i can not make it.. could you send for me a tutorial or code to help me..


    thanks in advance
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Dec 2004
    Posts
    2,996
    Rep Power
    375
    how about you google "htaccess URL re-writing", you will see LOTS of posts

IMN logo majestic logo threadwatch logo seochat tools logo