4

If you put this in your .htaccess file

Options MultiViews

and you have these files

stuff/
    howto.html
    index.php
    items.php

then all of these web addresses work

/stuff/           # brings up /stuff/index.php.
                  # Yes, this would have worked
                 `# even without MultiViews

/stuff/howto      # brings up /stuff/howto.html.
                  #`This would not have
                  # worked without MultiViews,
                  # although you could have done
                  # it with a Rewrite rule, too

/stuff/items      # brings up /stuff/items.php

/stuff/items/1234 # brings up /stuff/items.php,
                  # and sets $_SERVER['PATH_INFO']
                  # to '/1234'

/stuff/items/2010/03/01/how-to-plant-a-garden
                  # brings up /stuff/items.php, and
                  # sets $_SERVER['PATH_INFO']
                  # to '/2010/03/01/how-to-plant-a-garden'.
                  # If my file layout was different,
                  # like /stuff/items/2010.php,
                  # then it would have brought up
                  # 2010.php, and given it the PATH_INFO
                  # string of '/03/01/how-to-plant-a-garden'
                  # So it seems Apache searches the string
                  # from right to left for a file

Putting MultiViews in the .htaccess file is much shorter than using Rewrite rules.

But now I am looking at nginx, and I have yet to find the equivalent. It doesn't have to be so short. I know try_files would take care of the ones without PATH_INFO strings. But for the ones with PATH_INFO, the only way I've found is a Rewrite rule for each PHP file, especially the ones that take slashes in PATH_INFO.

  • 1
    I don't think so, NGINX is built for performance and MultiViews is a BIG performance hit, it should definitely NOT be used on a production website. It's also worth noting that if you're using MultiViews Google won't index your site properly (See http://www.gerd-riesselmann.net/archives/2005/04/beware-of-apaches-multiviews) –  Jun 07 '11 at 20:45

0 Answers0