Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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'm working on some old PHP code of mine that was previously served using Apache+Multiviews+PATH_INFO. I'm now trying to get this site up and running using nginx (which I use and adore for all of my other more recent work).

The issue is with URLs such as /books/newreleases/1420, which actually needs to be handled by /books.php (so that php sees /books.php/newreleases/1420 with appropriate PATH_INFO info available).

I know all of the reasons why such use of multiviews is a bad idea, but redeveloping this site to work around it is not currently an option.

I can make this specific example work through use of rewrite: (rewrite ^/books/(.*)$ /books.php/$1;) but there are too many files across the entire site to make manual coding of rewrites for each anything other than a last resort. Plus, it makes me sad.

I've been reading through all of the similar questions on here but can't find an answer to this specific case, nor can I quite figure out if there's a correct way to use try_files to handle it.

Here's the meat of my config as it stands:

server {
    root /srv/www/;
    rewrite_log on;
    index index.html index.htm index.php;

    location / {
        rewrite ^/books/(.*)$ /books.php/$1;
        try_files $uri $uri.php $uri/ =404; 

    location ~ ^.+\.php {
        try_files $uri.php $uri/ =404;
        include /etc/nginx/fastcgi_params;
        fastcgi_index index.php;
        fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
share|improve this question

Your Answer


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

Browse other questions tagged or ask your own question.