DISABLE ADBLOCK

ADBlock is blocking some content on the site

ADBlock errore

In RewriteRule if pattern and substitution begin with the same string, the RewriteRule doesn't work. Why?

StackOverflow https://stackoverflow.com/questions/20301743
 Checked

Question

In this post: My previous post i was asking help for a strange issue: a correct regexp was not working in a RewriteRule. After hours of work i found how to fix the error and i found out this strange thing.

If i write this rule in .htaccess:

RewriteRule ^rankings\/[a-zA-Z0-9\-]+\.html$ /rankings.php

and type this URL

http://www.mywebsite.net/rankings/classifica.html

I get a 404 Error. Even if the Regexp is correct, the apache RewriteEngine is not working. Instead, if i write this rule:

RewriteRule ^ran-kings\/[a-zA-Z0-9\-]+\.html$ /rankings.php

and type this URL

http://www.mywebsite.net/ran-kings/classifica.html

Everything works fine. I made many other tests with different rules and pages and i always got the same problem. The conclusion i came to is that if the pattern and substitution begin with the same word, the RewriteRule doesn't work.

How come is this possible? Anybody knows why this happens?

Solution

Actually real problem is the MultiViews option. Multiviews allow substitutions of file extensions, so you can call an URL like http://www.example.com/page.php using http://www.example.com/page.

Use this line on top of your .htaccess to disable it:

Options -MultiViews
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow