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.
In /etc/apache2/httpd. conf you should find the section starting <Directory "/Library/WebServer/Documents"> and remove MultiViews from the Options directive there.
Save the file and type the URL yoursite.com/foobar/ . If the reditect works and the URL gets redireted to the homepage of example.com then it's clear that your htaccess is working and being read by your Apache server. If it still doesn't work then the problem might be that your hosting provider has not enabled it.
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 htaccessOptions -MultiViews
This way, your rule will be now evaluated because content negotiation is disabled.
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With