A rear-ported speaker can be designed specifically to work well up against a wall or even in a corner (a la Audio Note). In my opinion it's actually easier to achieve a frequency response curve that is the approximate inverse of anticipated boundary reinforcement using a ported box rather than a sealed box.
Here are the reasons why rear porting done right (that is, appropriately taking boundary reinforcement into account) is preferable to front porting:
1. Rear porting displaces the bass sources relative to one another as much as is feasible. With the port on the front, your two bass sources (the woofer and the port) are the same distance from the wall behind the speaker, and so their room-interaction will be fairly similar. With the port on the rear, your two bass sources are a significantly different distance from the wall behind the speaker, and thus their individual room-interaction peak-and-dip patterns will be different and tend to average out to a smoother net curve.
2. Any port tube resonances or residual midrange energy emerging from the port will be less audible with the port on the rear of the enclosure because it will be farther from the listener's ears.
3. Since a rear-mounted port will usually get a bit more boundary reinforcement than a front-mounted port, in practice this allows a bit deeper in-room extension - assuming proper tuning.
Of course you want to provide adequate clearance for the port to breathe, but what happens if you don't? Well in that case the nearby wall extends the effective port length a bit, which lowers the tuning frequency a bit, which is the direction you want to go if you're getting a lot of boundary reinforcement anyway.
Now intuition would lead you to believe that you'll get less bass impact from a rear-firing port because of the path length difference, but this is one of those cases where our intuition is misleading. Controlled studies have shown that the ear cannot even detect the presence of bass energy before at least one wavelength has reached the ears, and that several wavelengths are needed to detect pitch. So the small fraction-of-a-wavelength time smear between the arrival of energy from the woofer and from the rear-firing port is not of audible significance. In fact I believe that the in-room frequency response curve is by far the best predictor of subjective bass quality, but that's a tangential topic.
So while as a general rule-of-thumb most rear-ported speakers may be unsuitable for placement very close to the wall, there are exceptions.
Duke