Logout From .htpasswd Protected Site

Using .htaccess with .htpasswd is an easy way to add simple protection to a site. But once logged in there is no easy way to log out.

Image credit

One way to force logout is closing the browser (with all its windows) but that's way too radical.

Fortunately visiting the a link like this should also work in most cases.

http://logout@example.com/

You can type it every time to the URL bar, or create a bookmark with this in the URL field:

javascript:document.location=document.URL.replace("://","://logout@");

What it does is simply replace the :// with ://logout@ in the document url, so it works with both http and https sites.

Now you just need to click on the bookmark and you'll be logged out.

Note: unfortunately Chrome doesn't allow creating a bookmarklet of such "javascript:" type links, that's why there's no bookmarklet in the post anymore.

0 comments Comments