[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[EP-tech] Adding 301 redir_permanent for some migrated items before 404 kicks in.

CAUTION: This e-mail originated outside the University of Southampton.
Hi All,

Running 3.3.16.

Looking to migrate some records from our primary system to a secondary system, and redirect all the bots we've collected over the years, via redir_permanent (301), for the migrated items to the new location (rather than have the primary show a 404).

I have based my initial attempt which is working, on the logic in cfg/cfg.d/rewrite_url_demo.pl, but it fires for every uri hit the server sees,... valid records, css, etc...

Is there a way to allow the system to function as usual, and then if the uri request cannot be found, fire this particular redirect logic, and if it falls through that, then present the 404 as usual??
Primarily just to keep the trigger from firing until needed... since I don't need the trigger to lookup potentially ~000's of eprintid's, for every uri request coming through...

Original logic,
# $c->add_trigger( EP_TRIGGER_URL_REWRITE, sub {
#             my( %o ) = @_;
#             if( $o{uri} eq $o{urlpath}."/testpath01" )
#             {
#                             ${$o{return_code}} = EPrints::Apache::Rewrite::redir( $o{request}, https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Ftotl.net%2F&data=05%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7C5a431bfaf17d4bd058cb08db0ef1d5c5%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C638120204796925810%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=q6MzgSX%2BH8sKyilwWHYhNJ8GDkiwFnLcZlatCQg%2BAlY%3D&reserved=0 );
#                             return EP_TRIGGER_DONE;
#             }
# } );

Updated to
# $c->add_trigger( EP_TRIGGER_URL_REWRITE, sub {
#             my( %o ) = @_;
#             my $url = $o{uri};
#             if( $url =~ m#^/(\d+)/#  || $url =~ m#^/id/eprint/(\d+)/# )            # <-- This snippet taken from cgi/handle_404
#             {
#                             if( $1 eq "99999" )
#                             {
#                                             ${$o{return_code}} = EPrints::Apache::Rewrite:: redir_permanent ( $o{request}, https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fnot.the.real.link.net%2F&data=05%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7C5a431bfaf17d4bd058cb08db0ef1d5c5%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C638120204796925810%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=x7cZ6KuFGTTPeF1POvr2gKaqklnn0%2BUn93DYTD9jQx8%3D&reserved=0 );
#                                             return EP_TRIGGER_DONE;
#                             }
#             }


This email (including any attached files) is confidential and is
for the intended recipient(s) only. If you received this email by
mistake, please, as a courtesy, tell the sender, then delete this
The views and opinions are the originator's and do not necessarily
reflect those of the University of Southern Queensland. Although
all reasonable precautions were taken to ensure that this email
contained no viruses at the time it was sent we accept no
liability for any losses arising from its receipt.
The University of Southern Queensland is a registered provider
of education with the Australian Government.
(CRICOS Institution Code QLD 00244B / NSW 02225M, TEQSA PRV12081)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ecs.soton.ac.uk/pipermail/eprints-tech/attachments/20230215/d8ec03a3/attachment.html