Page 1 of 1

How to prevent users from viewing certain pages?

Posted: Sun Jul 11, 2010 4:59 pm
by Smudly
Hi, I need to add some security to some pages and even some directories so users are not able to view them. What do I need to do to prevent users from viewing pages?

Re: How to prevent users from viewing certain pages?

Posted: Sun Jul 11, 2010 5:56 pm
by morris520
1: try to read something about HTAccess, e.g. Forbidden page
2: If you want to do it in programming aspect, you can add an index.php to each of your dir. Then write if-statement to redirect them to other pages.

Hope this helps

Re: How to prevent users from viewing certain pages?

Posted: Sun Jul 11, 2010 8:13 pm
by rhecker
The method I use to protect directories is the method Morris touched on. Run htpasswd from the Apache BIN directory to encrypt the password. Take the file containing this and put it above the website root, where others cannot access it. Then place an .htaccess file in any directory you want to protect. The contents of this file will look somethng like this:

Code: Select all

authtype basic
authname ADMIN
authuserfile /data/18/1/130/82/78421/user/1745722/cgi-bin/.admin
require valid-user
Here is the url for the htpasswd command line arguments:

http://httpd.apache.org/docs/2.0/programs/htpasswd.html

Re: How to prevent users from viewing certain pages?

Posted: Mon Jul 12, 2010 3:15 pm
by hag
use sessions or the other ideas.. if interested post back and I'll provide more info

I didn't want to include too much if you were going with the other ideas.

Hag

PS I only use htaccess to provide a "window" for web clients before their site goes live, everthing else I use sessions