Skip to main content

2 posts tagged with "apache"

View All Tags

PHP binding for Apache Qpid's Messaging API

· 2 min read
Apache Qpid™ Logo

Apache Qpid™ is a high performance open-source message queuing system. But there's no point me telling you all about it - just check it out over at http://qpid.apache.org/.

The Qpid project provides two different message brokers, and several client APIs. However it did not yet have a PHP client API, so I set about writing one :)

Although the PHP binding I created is SWIG-based, it was not as straight-forward as writing a simple SWIG interface file, and compiling... no sir! First off, running SWIG on the standard Qpid headers in PHP mode resulted in SWIG seg-faulting. So after reporting that bug to SWIG (it has since been fixed, yay!) and developing a workaround, I then had to solve a number of small issues, and then write some Qpid Variant ⇔ PHP type-mapping routines.

Improving Apache's canonical hostname rewrite rules

· 2 min read

According to the Apache URL rewriting guide, the way to handle Canonical Hostnames is like this:

RewriteCond %{HTTP_HOST}   !^fully\.qualified\.domain\.name [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^/(.*) http://fully.qualified.domain.name/$1 [L,R]

Well, those rules are not always sufficient. Specifically, what if you also owned the www.example.com.au domain, and wished to redirect it also to the primary www.example.com domain? The solution is simple - we just need to add a single $ character to the end of the match-pattern of the first RewriteCond like this:

RewriteCond %{HTTP_HOST}   !^fully\.qualified\.domain\.name$ [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^/(.*) http://fully.qualified.domain.name/$1 [L,R]

Now that will work nicely as long as the hosts use standard ports (ie 80 for HTTP, and 443 for HTTPS). However, some Python versions unnecessarily append the standard HTTPS port number to the Host HTTP header. Also I discovered today (after some Apache debug logging) that Adobe AIR applications have the exact same misbehavior for HTTPS, but only when running under Mac OS X.