Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have the following config file that works for everything but PHP pages.

I am trying to get everything as an ancient_browser to add /IE/ in the URL. Essentially changing the root for these clients although you cannot set this within an if.

If I add the rewrite within the PHP location it doesn't work either. Any ideas?

location / {
    if ($ancient_browser) {
        rewrite  ^(.*)$ /IE/$1 break;
    try_files $uri $uri/ /index.php;

location ~ \.php$ {
            include /etc/nginx/fastcgi_params;
            fastcgi_index index.php;
            if (-f $request_filename) {
share|improve this question
Did you try putting the rewrite at the beginning or the end of the PHP location block? – mgorven Aug 9 '12 at 6:04
up vote 0 down vote accepted

Works for me (nginx 1.2.3):

    if ($ancient_browser) {
        set $ab "/IE";
    location / {
        try_files $ab$uri $ab$uri/ $uri $uri/ /index.php;
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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