Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I rewrite my .php files to .htm, using the following code in .htaccess file.

RewriteEngine on
Options +FollowSymlinks
RewriteRule ^(.+)\.htm$ $1.php [NC]

This is working fine. But now I want to restrict access of .php file directly.
As example: when people request index.htm he can see the content of index.php file, but if he request index.php then he will get an 404 error. How is it possible?

share|improve this question
add comment

1 Answer 1

RewriteRule .*\.php /404.htm

That's untested but basically I would redirect *.php to 404.htm and then create a 404.php to cater for that. Put this rule above your .htm to .php rule.

share|improve this answer
    
This is throwing an Internal Server Error. Error Details: "Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, admin@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log. Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request." –  chanchal1987 Dec 12 '10 at 15:03
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.