Creating redirects question

firesidelibrarian's picture

I am building a new site for an existing web radio program. The old site is homemade, and each episode has a unique identifier in the URL, for example:

http://northernspiritradio.org/index.asp?command=showinfo&showid=628645279260

The "showid" at the end is the unique identifier. Though I have not done so yet, I can add this to each corresponding episode.

When we re-point the domain name to the new site, people will keep getting 404 error messages unless I can get Drupal to find the correct episode.

Can anyone suggest a module that would help with this? Or is there another method that would work with Drupal?

Thanks in advance!

Comments

I would use:

mglaman's picture

I would use: https://drupal.org/project/redirect

You'll have to predefine everything, or catch as it goes. You can create redirects from admin page or individual nodes

How many redirects are you

greggles's picture

How many redirects are you talking about? If it's more than a few dozen then you'll probably want to write a custom module to do this.

Redirect or .htaccess

nmillin's picture

+1 to using the Redirect Module.

Another option that I use is redirects in my .htaccess file. Make sure you don't redirect a path that Drupal needs, otherwise you'll break your site (infinite loops & files can't be accessed). Some links to check out:

http://www.jessenicola.com/node/102 - (explains where to add redirects in .htaccess)
https://drupal.org/node/38960 - (D.org's info, but it is a little dated)

# https://httpd.apache.org/docs/2.2/rewrite/intro.html lists RegEx characters (^, $)
# https://httpd.apache.org/docs/2.2/rewrite/flags.html lists different flags
# http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritecond

-Nate

Used Redirect module

firesidelibrarian's picture

Thanks everyone for the ideas!
I ended up using the Redirect module, and am in the process of manually entering each redirect.
The only drawback to this method is that the visitor ends up with a crazy-long URL, for example:

From:
http://northernspiritradio.net/index.asp?command=showinfo&showid=678790999800

To:
http://www.northernspiritradio.net/episode/end-juvenile-prison

Ends up with this URL showing in the browser's window:
http://www.northernspiritradio.net/episode/end-juvenile-prison?command=showinfo&showid=678790999800

Okay, just 849 manual entries to go...

Why not automate it with a

j_ten_man's picture

Why not automate it with a script? I pulled this from the Redirect module recently for a project I'm going to work on - I have not tested it, just wanted to see if I could find an automated way to add redirects. You could certainly modify this as well to take fewer parameters...

<?php
function addRedirect($source_path, $redirect_path, array $redirect = array()) {
   
$source_parsed = redirect_parse_url($source_path);
   
$redirect['source'] = $source_parsed['url'];
    if (isset(
$source_parsed['query'])) {
     
$redirect['source_options']['query'] = $source_parsed['query'];
    }

   
$redirect_parsed = redirect_parse_url($redirect_path);
   
$redirect['redirect'] = $redirect_parsed['url'];
    if (isset(
$redirect_parsed['query'])) {
     
$redirect['redirect_options']['query'] = $redirect_parsed['query'];
    }
    if (isset(
$redirect_parsed['fragment'])) {
     
$redirect['redirect_options']['fragment'] = $redirect_parsed['fragment'];
    }

   
$redirect_object = new stdClass();
   
redirect_object_prepare($redirect_object, $redirect);
   
redirect_save($redirect_object);
    return
$redirect_object;
  }
?>

Wisconsin

Group organizers

Group events

Add to calendar

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: