Don't go there, friend… of meta refreshes and status codes.

I know I’ve been guilty of this one in the past, but I want you to make this pledge along here with me: “No more abuse of the meta refresh!”

I know — it’s a handy in so many ways. I used it most often as a way to create short URLs for my visitors that would redirect to a page with a longer, more complicated URL. I’d create a directory off of the root of a site and pop an index.html in the directory that would include a meta refresh to send visitors on to another page.

“So, what’s the deal?”

While the meta refresh appears to do the job, it’s not the best method to acheive this result. Two problems spring to mind… Firstly, it mucks up your visitor’s browser history. If they try to hit “back” from the page you redirected to, they’ll quickly find themselves back on the page, since the meta refresh will do it’s thing and redirect them again. The other issue is that most reputable search engines typically ignore meta refreshes. They have long been abused by search engine spammers and the search indexers have adapted.

The answer?

Use the 301 “Moved Permanently” status code. The 301 status code tells browsers and search indexers that the content they are looking for can be found in another location. It’s Google-friendly and preserves your users’ browser history.

But how?

If you’re using Apache, it’s a matter of updating your .htaccess file. I’m a ColdFusion guy, myself and the following code works for me:

<cfheader statuscode="301" statustext="Moved Permanently">
<cfheader name="Location" value="">