Tom
Tom

Reputation:

Redirect to 404 if .php extension is requested

When a user requests a page that ends with .php, I want to send them a 404 error even if the page exist. Is that possible to do with .htaccess/mod_rewrite??

http://mysite.com/whatever.php

Upvotes: 1

Views: 244

Answers (2)

Brad
Brad

Reputation: 163602

To anyone looking for the answer to this question on IIS, you can use the annoying "feature" in IIS where it doesn't return files of types that aren't in the MimeMap Metabase. That is, if IIS doesn't know what the file type is, it will return a 404.

This is documented on TechNet, along with information on how to edit the Metabase.

Upvotes: 0

Rob
Rob

Reputation: 48387

Haven't tested this, but it's something like:

RewriteRule \.php$ - [R=404]

Note: The Added Bytes mod_rewrite cheat sheet is a useful resource to have handy.

Upvotes: 4

Related Questions