EPrints Technical Mailing List Archive

Message: #08892


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

Re: [EP-tech] redirect some eprintid url to another site


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

Hi David!


 being it almost 99% of the archive and some thousands of items, it is quite difficult to have thousands lines $c->{rewrite_exceptions} but seems the only possible path, being the perl handler running before rewriterule. In other cases, it is possible to use LocationMatch to set the default handler thus running rewrite rules.


Another option could be rename the old archive? Thus we could use the virtualhost to do just redirects, and access old items (we need them internally anyway).


Other than changing the base url, change apache configs, running generate_static / generate_abstracts, what would I need to rename the old archive?


Il 14/03/22 18:00, David R Newman ha scritto:

Hi both,


I have been doing something similar recently, albeit for abstract pages.  I prefer the brute force approach of adding to $c->{rewrite_exceptions} and them manually adding the Apache Mod Rewrite rules to an archive level file called cfg/apache_redirects.conf and then including that in  cfg/apachevhost.conf and/or ssl/securevhost.conf.  You could write a script to programmatically generate this and the cfg.d file for rewrite_exceptions from a mapping file.


I had considered doing something that would allow you to add a metadata field called redirect_url or similar that you could just edit as a user (probably an admin or editor only if the item is live), which could then be used to automatically redirect off site.  However, that would require some changes at a core level, which feels a bit excessive for tackling this problem.


One option, if you want to redirect just from abstract pages, is you could test for this new redirect_url field being set and if it is embedding some _javascript_ in the abstract page that redirects to the new URL.  That is a bit hacky but makes it easier to add new items to be redirected in future rather than having to maintain a mappings list independent of the database.  However, this is no use if you want to redirect document URLs.  I am not sure whether that is what you want to do?


Regards


David Newman



On 14/03/2022 4:07 pm, Yuri via Eprints-tech wrote:
CAUTION: This e-mail originated outside the University of Southampton.

Hi John!


 thanks for sharing the gist. The objects are about 10.000, so I should load the map from a file. Unfortunately, It is an old Eprints without the EP_TRIGGER_URL_REWRITE but I think I just can copy the code at the begin of Rewrite.pm.


Thanks!


Il 14/03/22 16:35, John Salter ha scritto:
Hi Yuri,
I would use the EPrints URL Rewrite trigger.

How many items are mapped to the other system?
Do you want to map landing page requests to one URL, and document requests to another URL (e.g. directly to the document in the other system)?

This gist: https://gist.github.com/jesusbagpuss/a5c574e1839612ef7e332d1d25edac42 allows you to specify the eprintid / new locations in a hash.
If all the new locations are on the same site, you could update line 19 to include the new base http URL, and just have the eprintid => otherid in the hash.

As written, it will capture requests for anything starting with the EPrintID (requests for the landing page; downloads; thumbnail requests).
You could map these URLs individually, and change the regex match on line 13 to redirect document requests to the new document URL; landing page requests to the new landing page etc.

Hope that helps - let me know if you need more info.

Cheers,
John




From: eprints-tech-bounces@ecs.soton.ac.uk <eprints-tech-bounces@ecs.soton.ac.uk> on behalf of Yuri via Eprints-tech <eprints-tech@ecs.soton.ac.uk>
Sent: 14 March 2022 13:45
To: EPrints.org Technical List <eprints-tech@ecs.soton.ac.uk>
Subject: [EP-tech] redirect some eprintid url to another site
 
CAUTION: This e-mail originated outside the University of Southampton.

Hi!

  we're migrating many objects from eprints to various other platform. I
would like to make redirects for the URLs of this documents. For example
from myeprint.com/eprintid to another.site.com/otherid (I have a map
with eprintid otherurl)

I'm trying to do it with RewriteMap and RewriteRule but Eprints define
the perl handler to manage urls (PerlTransHandler
EPrints::Apache::Rewrite) to handle rewrites. I would like not to use
cfg.d/url.pl because there are a lot of objects.

Any idea? Should I patch Rewrite.pm to do it internally from a mapfile?
Return DECLINED? I don't know if it is worth the time, I would prefer a
simpler solution.


*** Options: https://eur03.safelinks.protection.outlook.com/?url="">
*** Archive:
https://eur03.safelinks.protection.outlook.com/?url="">
*** EPrints community wiki:
https://eur03.safelinks.protection.outlook.com/?url="">

*** Options: http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech
*** Archive: http://www.eprints.org/tech.php/
*** EPrints community wiki: http://wiki.eprints.org/