2

I'm trying to configure Nginx on a new server. I have a number of PHP scripts (f.e. /test/test.php) and I want to use this scripts "as is" (default language, English), as well as with language redirecting. Example - when "/de/test/test.php" is requested,

  1. nginx writes a cookie (lang=de)
  2. and returns "/test/test.php" (without modifying URI, so that visitor remains on "/de/test/test.php"

Any help is greatly appreciated! I already lost several nights fighting with this, and I'm getting desperate enough to cancel new server and return back to shared hosting.

Thanks!

2

Please let me know if it works:

location ~ \.php$ {
    location ~* /(de|fr)/test/test\.php$ {
        set $lang $1;
        add_header  Cookie 'lang=$lang';
        rewrite (.*) /test/test.php last;
        break;
    }
    fastcgi_pass 127.0.0.1:9000;
    include fastcgi.conf;

    fastcgi_intercept_errors        on;
    error_page 404 /error/404.php;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.