December Sun – A Web Comic

March 29, 2009

The 301 redirect

Filed under: 3,computers,misc,programming,web comics — admin @ 11:05 pm

an image that has nothing whatsoever to do with this post, from DS #5

 

 

 

I’ve been hammering out the woes with this webcomic since December of last year, and one of the things from the beginning that’s puzzled me is the fact that the basic URL is supposed to be:

 

http://www.dscomic.com 

…yet all of the actual site content is stored away in 

http://www.dscomic.com/wordpress-2.6.3/wordpress/

(in and of itself a problem, as what happens to this directory structure if I decide to upgrade WordPress?  Am I going to be stuck in 2.6.3?)  

Anyhow, the problem was that I wanted the primary site to be DSCOMIC.COM, yet I had to redirect the site visitor to the wordpress directory.  What I had been doing originally was an HTTP redirect, using the following logic:

<meta http-equiv=”refresh” content=”1; URL=http://www.dscomic.com/wordpress-2.6.3/wordpress/”>

This worked, I suppose, but never seemed like the right option, since when you’d go to DSCOMIC.COM first, you’d be at a blank white page with the text “December Sun”, then you’d be routed to the index file in the  /wordpress sub-directory with all of the site content and goodness.  I suppose I could have kept doing this, but it seemed like this wasn’t the most efficient way to go (and I seem to recall reading in the “Building Findable Websites” book that these sort of redirects weren’t a good thing for a site, as far as search engine ranking went.

So I dug around a little more, and found a more simpler option: now if the user starts at DSCOMIC.COM, the following springboard kicks into play to shoot the user over to the wordpress subdirectory.  Instead of an index.html file with the meta listed below, it’s just an extremely simple PHP program that quickly does the move…. 

<?php

header(“HTTP/1.1 301 Moved!”);

header(“Location: http://www.dscomic.com/wordpress-2.6.3/wordpress/”);

exit();

?>

I thought I’d share this here, in case this of any benefit to anyone.  More than likely, though, is that this post will just elicit eye-rolling from readers as to my total naivety with PHP and redirects.  Ah well, I just like drawing funny books…

Powered by WordPress