46

I've been struggling a lot with an access rule that needed to rewrite one piece of URL adding a path.

RewriteRule ^(configuration/.+)$ application-server/$1 [L,NC,R=301,NE]

This Rule caused just a blank page on my Joomla site with no error log or messages. The curious thing is that all other rules I had worked perfectly:

RewriteRule ^(log/.+)$ application-server/$1 [L,NC,R=301,NE]
RewriteRule ^(monitor/.+)$ application-server/$1 [L,NC,R=301,NE]

in the end, I've found in a forum a suggestion to use the following option:

Options -Multiviews

That actually solved the issue, however I wonder if there can be any side effects on other Rules when using this option.

Cœur
  • 37,241
  • 25
  • 195
  • 267
user2824073
  • 2,407
  • 10
  • 39
  • 73
  • Did you bother to take a look into the documentation? I just ask because you mention no such thing ... – arkascha Aug 29 '23 at 20:46

1 Answers1

85

This is about Apache content negotiation.

A MultiViews search is where the server does an implicit filename pattern match, and choose from amongst the results.

For example, if you have a file called configuration.php (or other extension) in root folder and you set up a rule in your htaccess for a virtual folder called configuration/ then you'll have a problem with your rule because the server will choose configuration.php automatically (if MultiViews is enabled, which is the case most of the time).

If you want to disable that behaviour, you simply have to add this in your htaccess
Options -MultiViews

This way, your rule will be now evaluated because content negotiation is disabled.

Edit

On some shared hostings, the negotiation module might not be enabled. That would give you then a 500 error. To avoid this error, you can, by default, encapsulate the directive in an IfModule block.

<IfModule mod_negotiation.c>
    Options -MultiViews
</IfModule>
JoSSte
  • 2,953
  • 6
  • 34
  • 54
Justin Iurman
  • 18,954
  • 3
  • 35
  • 54
  • 2
    Thanks, I can see the culprit now! that's because joomla has also a phisical folder called configuration. – user2824073 Aug 22 '14 at 10:39
  • 2
    FWIW, `Options -MultiViews` doesn't result in a 500 error when mod_negotiation is not enabled. It doesn't even result in a 500 error if you try to _enable_ MultiViews (when mod_negotiation is not enabled) - when maybe it should? However, mod_negotiation is a "Base" module - which means it is "compiled and loaded into the server by default", so it is rare for it to not be available, even on a shared server. – MrWhite Mar 05 '18 at 00:40