is there any update in quue for bulk redirect operations?
it could be very useful, instead of fixing every 404 click by click through the ui.

CommentFileSizeAuthor
#6 redirection_bulk_import.zip1.66 KBcarsonblack

Comments

noah’s picture

It used to be possible to add redirects in bulk directly to the database, but now because of the hash it no longer is. Some way of importing would be extremely useful.

duckydan’s picture

Yeah, I really need this too! I was just about to import tons of entries because of an unusual circumstance. But now I see my plan won't work because of the hash. Why is this done this way? I was about to dig through the module code to find how the hash is generated and maybe make a loop to generate them after the rows are added. Any guidance would be helpful.

duckydan’s picture

Maybe I am wrong, but the hash just seems to be a unique value to avoid duplicates. Perhaps if you import the redirects in bulk, including a random bunch of data for the hash, it might do the same thing. I will report back my findings.

simondoyle’s picture

I can confirm that duckydan is correct - the hash can be randomly generated - it's just used as a unique ID - so a bulk import is possible through the DB table.

guntervs’s picture

You can use hash function provided by the module as well: redirect_hash();

function redirect_hash($redirect) {
  $hash = array(
    'source' => $redirect->source,
    'language' => $redirect->language,
  );
  if (!empty($redirect->source_options['query'])) {
    $hash['source_query'] = $redirect->source_options['query'];
  }
  drupal_alter('redirect_hash', $hash, $redirect);
  redirect_sort_recursive($hash, 'ksort');
  $redirect->hash = drupal_hash_base64(serialize($hash));
  return $redirect->hash;
}

I'm now working on an import module and try to use as much of the functions provided by the module itself. When I've got working code, I'll share it here.

carsonblack’s picture

StatusFileSize
new1.66 KB

Attached is a little module I wrote that will allow you to point to a CSV file of redirects (source,target) and bulk import redirects. The page to set the CSV file is at admin/config/development/redirection-bulk-import. Just make sure you have permissions to open the file.

NOTE: this is not a patch to the redirect module, it is stand-alone, but has a dependency on the redirect module.

ANDiTKO’s picture

@carsonblack Many Many Thanks to you my friend!

Your module solved me two of my problems.
1) I am now able to bulk import my 1000+ urls very fast without clicking around.
2) I can now import utf8 uni-coded URLs.

Here is some tips for other people that might want to use it.

1) Download and enable the redirection_bulk_import.zip module.
2) Create your CSV file with your first column containing the "Source URI" and the second column the redirect URL. If you dont have CSV editor or you are having troubles with character encoding try Google Docs. Make a spreadsheet and download it as CSV.
3) Upload your CSV to your server location. For example upload it to "sites/default/files/redirects.csv" and write that path to the module form located at "admin/config/development/redirection-bulk-import".
4) Press the "Submit" button. If you get succsessful message then you are good to go. If not try clearing your old redirects before doing the import. Or check your CSV file. Try something small first.

Hope my tips helps ;)

Thanks again carsonblack!

plopesc’s picture

Hello
There is a contributed module, Path redirect import that provide full featured bulk redirect from CSV.

pere orga’s picture

Issue summary: View changes
Status: Active » Fixed

Yes, import can be done using that module.

And at this point it would make much more sense if these type of features are implemented separately, by other contrib modules. At least until we have a stable release.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.