EPrints Technical Mailing List Archive

Message: #09200


< Previous (by date) | Next (by date) > | < Previous (in thread) | Next (in thread) > | Messages - Most Recent First | Threads - Most Recent First

[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://totl.net/ );

#                             return EP_TRIGGER_DONE;

#             }

# } );

 

Updated to

# $c->add_trigger( EP_TRIGGER_URL_REWRITE, sub {

#             my( %o ) = @_;

#             my $url = "">

#             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}, http://not.the.real.link.net/ );

#                                             return EP_TRIGGER_DONE;

#                             }

#             }

 

 

Cheers,

 

Matt.

__________________________________________________________________
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 
email.
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)