awm
awm

Reputation: 1200

.htacess rewrite rule not working for a specific string?

I have the following rewrite rule

RewriteRule ^healthcheck/?$ /README.txt [NC,L,R=307]

in my .htaccess. What's strange about it is that when I change the string healthcheck to any other string the rewrite rule works. What am I missing?

Upvotes: 1

Views: 101

Answers (1)

Jon Lin
Jon Lin

Reputation: 143846

If you have a file called healthcheck.php and that is causing this rule to not get applied:

RewriteRule ^healthcheck/?$ /README.txt [NC,L,R=307]

It sounds like you need to turn off multiviews, which is part of mod_negotiation and supercedes whatever mod_rewrite rules you have. Mod_negotiation will see the request /healthcheck and then see that there's a file called /healthcheck.php and assumes that the request was really for the php file. Turning it off will end up having mod_rewrite handle it:

Options -Multiviews

Upvotes: 1

Related Questions