I've found out that due to the way HTTP Basic Authentication works I need to unauthorize a client in order for the browser to forget the session id. I found a way to do that but I still need to send log out query after unauthorization. I changed the logout request to redirect it to the unauth url, in my django views.py function for logout. But I could not find any way to redirect the client to previously mentioned logout url afterwards, since the logout function can only return one response. Any questions regarding why can't I logout (How do I log out?" Short Answer: "You can't. Sorry.)
I tried to find the apache2 default handler for 401 and redirect any 401's to the logout url, but I could't.
I tried to add a custom handler in django for 401 exception, but I still couldn't get django to detect the 401. It seems like only apache handles it.
How can I redirect a client to another url(logout) after he has received 401 Unauthorized?
Better yet, how can I handle 401 in apache?