Mobile app version of vmapp.org
Login or Join
Alves908

: Restrict access of rewriting file using .htaccess I rewrite my .php files to .htm, using the following code in .htaccess file. RewriteEngine on Options +FollowSymlinks RewriteRule ^(.+).htm$ .php

@Alves908

Posted in: #Htaccess #UrlRewriting

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

RewriteEngine on
Options +FollowSymlinks
RewriteRule ^(.+).htm$ .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?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Alves908

1 Comments

Sorted by latest first Latest Oldest Best

 

@Connie744

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.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme