Kuartz
Kuartz

Reputation: 302

forbid direct access to php files (MVC)

My files are organized with the MVC pattern (Model, View, Controller).

How am I supposed to protect files in these folders from direct access?

For example, I would like to forbid user to write manually "http://VIEW/blabla". Indeed, the only files which would be supposed to be accessible are outside the folders. They just call, with 'include' php function, the other files contained in VIEW, CONTROLLER and MODEL.

If I protect these folders, when I have something like :

<form action="MODEL/userCreate.php" method="post" id="form">

Will the code be blocked by my protection?

Upvotes: 1

Views: 77

Answers (1)

Paul Dixon
Paul Dixon

Reputation: 300975

Put those folders outside your document root

/project
    /src   <-------------your code, not served over http
        MyClass.php
    /web   <-------------your document root, served over http
        index.php

Upvotes: 1

Related Questions