Reputation: 333
For example: www.example.com/about.php
I don't want the files with the extension .php to be available to reach, display a 404 page instead.
I have the files in the root folder: content.php about.php footer.php etc... Now i can reach these files by typing in to the adress bar. I want to restrict this.
How can i do that?
Upvotes: 0
Views: 889
Reputation: 14946
A better approach that avoids the overhead and complexity of mod_rewrite is to simply not put files you don't want reached by url in the root folder. You can just put them somewhere else and include them from there; simple and (more) secure, but for some reason this doesn't seem to be common knowledge.
An example structure might be
project/
project/root
project/lib
Your public code (e.g. index.php) would live in project/root, and that would be the website root. Your included code would live in project/lib can be easily included using require, include, etc.
No mod_rewrite. Very simple.
Upvotes: 6