Thursday, December 18, 2014

.htaccess and .htpasswd leads to 404 error

When you have .htaccess and .htpasswd to protect a folder on the server like this:

.htaccess:
AuthName "Restricted Area"
AuthType Basic
AuthUserFile /path/to/.htpasswd
AuthGroupFile /dev/null
require valid-user
.htpasswd:
user:password
Possibly it will be a 404 error when you access the folder from the web. Deleting .htaccess and .htpasswd, it will be fine again.

This is because Apache tries to look up the 401 document or whatever when it can't locate it. Just add this line to the end of .htaccess and the problem will go away.

.htaccess:
AuthName "Restricted Area"
AuthType Basic
AuthUserFile /home/thedatap/public_html/captain/.htpasswd
AuthGroupFile /dev/null
require valid-user
ErrorDocument 401 "Authorization Required"
 That's it. Try again and it will work now!

Monday, October 27, 2014

MySQL WHERE vs. HAVING

With a SELECT ... FROM ... WHERE ... GROUP BY ... HAVING ... query, MySQL first selects rows from the table(s) by evaluating the WHERE conditions. These rows are then grouped by GROUP BY clause and further filtered by the HAVING clause.

Conditions in WHERE clause are applied for SELECT, before any GROUP BY operations.

HAVING conditions, on the other hand, are applied for GROUP BY operations, after SELECT is completed, therefore can have aggregate functions to be evaluated in the conditions.


Branched!

I have been blogging on Kavoir for 7 years or even more I don't remember. After hundreds of posts I decided I should probably start anew somewhere else. It's always exciting to start something new. It should be a habit of any entrepreneur to try new things.

This does not mean I abandoned Kavoir. On the contrary, Kavoir will continue to thrive as the main base but this place, Stargator.BlogSpot.com will serve as a outer post of mine, exploring the frontier.

Now that I'm here, expect me posting weird but useful bits and pieces about my journeys in an enterprising lifestyle.

Thanks for listening! Dismissed!