What is the purpose of Options MultiViews?

1

I saw a code .htaccess in the Laravel Framework, whose code snippet had this:

<IfModule mod_negotiation.c>
    Options -MultiViews
</IfModule>

What would this -MultiViews ? What does it do?

    
asked by anonymous 08.02.2017 / 14:08

2 answers

2

MultiViews functionality in your Application

This is an Apache content negotiation rule.

MultiViews enabled for your application, hides the extension of a file assuming it is a directory.

Here are examples of how the feature is used when it's working on your site:

  • In the example below with MultiView (disabled) you access your files from the site nome_do_arquivo.extensão

    www.yoursite.com/index.php

  • With MultiView enabled (enabled) your files, as nome_do_arquivo.extensão gets nome_do_arquivo , in this case hiding the extension, as in the example below:

    www.yoursite.com/index

  • To enable the function:

    Options +MultiViews
    

    To disable the function:

    Options -MultiViews
    
      

    Note : In the Apache configuration, using Options All does not enable the MultiViews option by default. The same should be done manually if desired.

    How It Works

    According to official documentation, the effect of MultiViews is as follows: if the server receives a request for /some/dir/foo , if /some/dir/ has MultiViews option enabled, /some/dir/foo does not exist, then server will read the directory looking for files named with foo.* , executing a type map that names those files, assigning them the same types of media and encoding as if the client had requested the file by name. Then, the server chooses the best match with the requirements of the request.

    Sources: Locaweb , Official Documentation

        
    08.02.2017 / 14:12
    1

    When MultiViews is enabled in your application, this will hide the extension of a file. Here are some examples below of how the feature on your site is used:

    1) In the example below with MultiViews (disabled) you will access the site files as: file_name.extension

    www.yoursite.com/index.php

    2) With the MultiViews feature (enabled) the site files as filename.extension will look like filename, in this case hiding the extension as in the example below:

    www.yoursite.com/index

        
    08.02.2017 / 14:14