Deny requests by IP address on an Apache server

It’s very unlikely that someone will legitimately access your web server by IP address in their web browser, and it’s almost guaranteed to be a bot of some sort. To prevent access to your server by IP address, it’s necessary to examine the host header in the HTTP request (HTTP_HOST in Apache) and then deny access if it evaluates to an IP address.

Read More

Regex to identify an IE 6 user agent without blocking MSIE 8 or 9 users

I recently had a need to block all IE 6 users from a website. After doing some log analysis, it looked like nearly every IE 6 user agent was some sort of bot or undesirable crawler. The browsing patterns made it very obvious that the requests were not coming from a human, and sometimes the same IP address would send different user agent strings on each successive request.

Read More

Adding a rel=canonical link in Wicket for duplicate content

Google recently introduced a new <link rel="canonical"> tag to help the search engine identify duplicate content across domains or pages. I’m working on a development project that contains many subdomains under a single domain to present content specific to various geographical areas. Some of the administrative pages under each subdomain contain the same content (such as About Us, Privacy Policy, etc.).

Read More

Apple Store's usability is great, but…

I’ve been eyeing a new MacBook Pro for a while and decided to pull the trigger during Apple’s Black Friday promotion. Since I wanted some custom upgrades, I bought it on Apple’s online store instead of at an Apple Store. Apple’s done a great job with their site’s usability, but I found a few things lacking with the experience.

Read More

Configure WiQuery to not import JQuery automatically

I’ve been working on a Wicket project that requires JQuery to be present on every single page rendered by Wicket. I do this by including a reference to JQuery from my base page. However, when I add a wiquery component to a subclass of my base page, it automatically inserts a reference to JQuery as well – resulting in markup that instructs the browser to download jquery.js twice from two different places.

Read More

Why Yoda conditions are bad and usage of Java's 'final' keyword is good

I came across some code a while back that made me pause for a moment as I figured out its meaning. This code used something known as a Yoda condition, also sometimes referred to as Yoda notation. In a conditional block, the operands on an operator are reversed, so that the constant expression is listed first instead of second.

Read More