Beware POST Request Redirects

You probably know that you should choose either or for your website, but allowing both of these effectively means that you are splitting your search engine ranking in two (if you care about such things). I use Dreamhost and they make it very easy to redirect all traffic to one or the other of these. They do this using a 301 (permanent) redirect. For example, if you type curl, you will see:

<TITLE>301 Moved Permanently</TITLE>
<H1>Moved Permanently</H1>
The document has moved <A HREF="">here</A>.<P>

You can easily set this up yourself in your Apache config or a .htaccess file.

Now, something I’ve managed to do twice in the last week is to POST a form to the www-version of my domain, which then was redirected to the non-www version. When this happens, all the POST data is lost! (See the Apache documentation.) So, remember, when creating a form set its action URL to whichever is the preferred variant of your domain name so that no redirect takes place.