Password Protection with htaccess on Rackspace Cloud Sites needs few extra steps to do otherwise the method is same that is normally done for any Apache2 webserver. Rackspace Cloud Sites is Application Platform as a Service (aPaaS) primarily targeted for hosting PHP-MySQL based web softwares including CMS and blogging softwares. Password Protection with htaccess on Rackspace Cloud Sites is actually not difficult, but for a new user it might take some time find it out. Here is how you can lock any folder or the root of domain hosted on Rackspace Cloud Sites with username and password.
Password Protection with htaccess on Rackspace Cloud Sites : Basics
There are many open source and free web softwares available on Github, installing them you can generate the .htaccess code if you want to use the feature and generate other .htaccess codes frequently. However, for the most; that much work is not needed.
The basic is that; the .htaccess will refer to a folder where the .htpasswd file will be. This .htpasswd file has this format to save the user name and password :
But what will happen if the .htaccess itself get hacked ? There will be no value of protection. So, that step must be done by adding allow / deny rule, see this guide :
Password Protection with htaccess on Rackspace Cloud Sites : Steps
There are three steps. We are taking that, you are using WordPress or some kind of CMS. Keep in mind, URLs with Query mark can escape this rule in case of WordPress. So, pretty urls must be working. Still there will be some URLs, which will escape. What we want to say, this is never a fool proof process. Except token based access control, it is not possible to secure in that way, still it does the thing you want. As you will need to create two dot files; for Windows OS, you can follow this method to create dot files. Or you can edit existing .htaccess file using Gedit. For Ubuntu or any other Linux, obviously you can easily create the dot files, for OS X you can use TextWrangler or any such code Editor. Obviously, there is Gedit for OS X too. The needed two files name are :
Now, if you do not want to use own hosted software to create the required codes; you can use this website’s online .htaccess Password Generator :
You will see, they are asking in point 2 :
Path to .htpasswd file relative to your server’s root directory
This is actually the Linux path. There are many ways to get this path in case of Rackspace Cloud Sites, as basically it is not configured like normal web server. First, if you create a php file and place it in the required directory and execute it on your browser like we do for our WordPress Plugin development or in case of WordPress, you will get in some Plugin’s info page; for example in WP Super Cache settings page :
Or officially you can find this on your Rackspace Cloud’s Control Panel’s > Cloud Sites > Click Website Link > Features Tab :