SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict Banana Man's Avatar
    Join Date
    Dec 2005
    Posts
    391
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    .htaccess mod_rewrite

    Hi,

    I have an english version of a website and need to make a german version of it. I am going to use the same root files for both sites and connect to the correct database with an IF statement depending on the base domain displayed in the browser.

    This all works fine except that the german website would have the english url's as well. I was thinking i could probably change them to german using mod_rewrite but i cant seem to do it so far. Does anyone know how i would write the .htaccess code to do this?

    Basically, if they are on the german version of the site and go to the url www.mysite.de/page/test.php i want the browser to appear as www.mysite.de/seite/prufung.php

    Thanks

  2. #2
    SitePoint Guru risoknop's Avatar
    Join Date
    Feb 2008
    Location
    end($world)
    Posts
    834
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    RewriteEngine on
    RewriteRule seite/prufung.php page/test.php [L]
    Try this but I'm an Apache noob so I don't guarantee it'll work.

  3. #3
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Other way round, that one is mapping the german to the english.

    However, doing this with .htaccess isn't really viable because you first need to check if they are requesting the german area of the site.

    So, when they choose to read it in german, set a session variable. Then, make a PHP file to check if they have a session variable stating that they want to read german, and if so use a header('redirect ...'); exit; on the correct page.

    It would be advisable to store an array of the english/german filenames, so that you can easily find the german file name from the english.

    Of course, if you're using a more MVC approach this would be MUCH easier. As you would always be requesting the same file anyway, it'd simply be a case of checking which language is set before instantiating the database object, THEN pass it to the controller and voila.
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  4. #4
    SitePoint Guru risoknop's Avatar
    Join Date
    Feb 2008
    Location
    end($world)
    Posts
    834
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Or you could just store only english content and use Gettext or something similar to translate to other languages. That would allow you to have relatively unlimited languages available.

  5. #5
    SitePoint Addict Banana Man's Avatar
    Join Date
    Dec 2005
    Posts
    391
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Thanks!

    Got it working with the mod_rewrite


Bookmarks

Posting Permissions

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