Results 1 to 9 of 9
  1. #1

    Simple Redirection Script - Help please!

    Hello,

    I have several domains that all point to my the same directory for my webpage, Super Segway, which is translated into multiple languages. For example.

    supersegway com (English)
    supersegway ru (Russian)
    supersegway lt (Lithuanian)
    supersegway ge (Georgian)
    supersegway ee (Estonian)

    Currently, when you go to any of those domains, they all go to the same page, and from there you have to click on the flag in the corner to change the language of the webpage.

    In the root directory of my account, I have different index files which are translated into these languages, i.e. indexlt.php for lithuanian, indexru.php for Russan, indexlv.php for Latvian. Is there a way I can forward the domain to a specific index FILE in my root directory, as opposed to forwarding the domain to just a directory? It would make things much easier instead of trying to put all the Russian files in one directory, all the Latvian files in another directory, etc... Can you forward a domain to a specific webpage, instead of to a directory? Otherwise all the domains will just forward to index.php, which will only be in one language, and users will have to change languages manually...

    I imagine i need an index.php file that detects which domain name was entered, and forward the user to the appropriate "language" accordingly. Any ideas? Thanks!

    Conrad

  2. #2
    Join Date
    Jan 2004
    Location
    NJ, USA
    Posts
    288
    This may not be the best way, but with PHP you can check the referer ($_SERVER['HTTP_REFERER']) in various if statements. It should output either http://domain.com or http://www.domain.com . Once you find a match, you set the header location to the correct domain, all from the one index.php too.

    Here's how I would do it...

    Code:
    if($_SERVER['HTTP_REFERER'] == "http://domain.ru" || $_SERVER['HTTP_REFERER'] == "http://www.domain.ru"){
       header("Location: indexru.php");
    }
    // Repeat this multiple times for each language, just changing them to their respective domains and pages
    That make sense? There might (and probably are) other/better ways to do it, but this should work.

  3. #3
    Join Date
    Jun 2003
    Location
    n/a
    Posts
    8

    country redirection

    Try one of the country (IP based) redirection scripts at hotscripts.com

  4. #4

    Redirect

    I tried copying and pasting the code you posted into my index.php file, but always get:

    Parse error: syntax error, unexpected T_STRING in /Users/Conrad/Desktop/TacoHTMLEditPHPCheckTemp.php on line 40

    When I try to access the page.

  5. #5
    Join Date
    May 2006
    Location
    EU & USA
    Posts
    3,684
    Try mod-rewrite if using Apache webservers, you are able to rewrite the URL when its started from a domain-name. i.e. http://yoursite.ru will become http://yoursite.ru/indexru.html

    This happens at server level and thus the best place to do this.

    An other option would use GEOIP databases to see where the visitor comes from and move them to the site automatically, please not that is never 100% accurate so leaving the customer to switch is still a good idea.

    Hope this information will point you in the right direction.
    cPanel Servers in Europe: Strasbourg (FR), Haarlem & Amsterdam (NL) & Kent (UK), USA (Los Angeles, St.Louis), Asia (Singapore) | Follow us at Twitter: @040hosting
    Shared | Reseller | (managed) Dedicated Hosting | Domain Registrar | SSL Registrar | Cloudlinux Partner| 040Hosting (Registered company #17093425 KVK Eindhoven, The Netherlands)

  6. #6
    Join Date
    Jul 2005
    Location
    Buffalo, NY
    Posts
    2,626
    It would probably be easiest to set up each of the domains and use a 301 redirect via htaccess:

    Options +FollowSymLinks
    RewriteEngine on
    RewriteRule (.*) http://www.yoursite.com/index.php?lang=eu [R=301,L]

    Of course you'd need to fix the link, but that should work.

  7. #7
    Quote Originally Posted by Conrad787 View Post
    Hello,

    I have several domains that all point to my the same directory for my webpage, Super Segway, which is translated into multiple languages. For example.

    supersegway com (English)
    supersegway ru (Russian)
    supersegway lt (Lithuanian)
    supersegway ge (Georgian)
    supersegway ee (Estonian)

    Currently, when you go to any of those domains, they all go to the same page, and from there you have to click on the flag in the corner to change the language of the webpage.

    In the root directory of my account, I have different index files which are translated into these languages, i.e. indexlt.php for lithuanian, indexru.php for Russan, indexlv.php for Latvian. Is there a way I can forward the domain to a specific index FILE in my root directory, as opposed to forwarding the domain to just a directory? It would make things much easier instead of trying to put all the Russian files in one directory, all the Latvian files in another directory, etc... Can you forward a domain to a specific webpage, instead of to a directory? Otherwise all the domains will just forward to index.php, which will only be in one language, and users will have to change languages manually...

    I imagine i need an index.php file that detects which domain name was entered, and forward the user to the appropriate "language" accordingly. Any ideas? Thanks!

    Conrad
    hi,

    there is a code from asp and php that allows you to understand the current or previous domain name. by using that you can understand which domain has been used and redirect to user to the related page.

    for example you can go to ibm.co.uk and it will redirect you to ibm.com/uk. it is using the coding i mentioned above. cant remember the command but it was somewhere under serverside commands.

    cheers,
    sami hostan

  8. #8
    Join Date
    Jan 2004
    Location
    NJ, USA
    Posts
    288
    Quote Originally Posted by Conrad787 View Post
    I tried copying and pasting the code you posted into my index.php file, but always get:

    Parse error: syntax error, unexpected T_STRING in /Users/Conrad/Desktop/TacoHTMLEditPHPCheckTemp.php on line 40

    When I try to access the page.
    What exactly is on line 40? Just so I can see where I wrote the code incorrectly.

  9. #9
    Join Date
    Dec 2007
    Posts
    34
    Quote Originally Posted by Conrad787 View Post
    I tried copying and pasting the code you posted into my index.php file, but always get:

    Parse error: syntax error, unexpected T_STRING in /Users/Conrad/Desktop/TacoHTMLEditPHPCheckTemp.php on line 40

    When I try to access the page.
    you probably need to rewrite http:// and location: for that syntax on each language.
    why not put files on those domains? as I thought that might be the most straight forward thing to do.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •