I'm new to PHP. So far I'm trying to create a login & registration system.

My goal is to have visible PHP pages and then only runnable PHP pages which sort of route traffic. I have a page login.php which is in the document root (/var/www/html).

There is a form which posts to scripts/checklogin.php. I set up scripts as a location in apache and to deny from all, in hopes that the PHP files in scripts would receive inputs via POSTs, process data, and then redirect accordingly via header(...).

I'm getting denied access issues when the request POSTs to scripts/checklogin.php, which I'm guessing is due to the deny from all.

Any ideas?

  • If you deny access to your scripts you won't be able to access them. That's what deny is for. Don't do it, and you should be fine. And now seriously, why do you need the scripts to be non-accessible? – Karol J. Piczak Apr 9 '11 at 20:05

You can put an .htaccess file in the scripts directory like that:

Deny from all

An just include the files you are going to use from your main scripts, so you cannot executem them from the browser (for example: http://localhost/scripts/test.php, will give you a 403 forbidden error); but include them, for example:


Is not denied the access; that's because they run in different layers.

I guess that was your doubt.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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