Password Protect a Directory with .htaccess Openshift

Want create site? Find Free WordPress Themes and plugins.

Password protecting a directory can be done several ways. Many people use PHP or ASP to verify users, but if you want to protect a directory of files or images (for example), that often isn’t practical. Fortunately, Apache has a built-in method for protecting directories from prying eyes, using the .htaccess file.

htpasswd openshift

In order to protect your chosen directory, you will first need to create an .htaccess file. This is the file that the server will check before allowing access to anything in the same directory. That’s right, the .htaccess file belongs in the directory you are protecting, and you can have one in each of as many directories as you like.

You’ll need first to define a few parameters for the .htaccess file. It needs to know where to find certain information, for example a list of valid usernames and passwords. This is a sample of the few lines required in an .htaccess file to begin with, telling it where the usernames and passwords can be found, amongst other things.

AuthUserFile /var/lib/openshift/xxxxxxxxxxxxxxxxxxx/php/.htpasswd
AuthName “Please Log In”
AuthType Basic
Require valid-user

Login to Openshift via SSH

cd php

htpasswd -c .htpasswd kelly >> Ask enter password

Now go your document root:

nano .htaccess

Copy top code into it. Done

Did you find apk for android? You can find new Free Android Games and apps.

You might also like More from author