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:

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!


I would use:

mglaman's picture

I would use:

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: - (explains where to add redirects in .htaccess) - ('s info, but it is a little dated)

# lists RegEx characters (^, $)
# lists different flags


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:



Ends up with this URL showing in the browser's window:

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...

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);