Forum Moderators: open

Message Too Old, No Replies

Need to redirect out of domain outgoing url's - reg exp

Need to redirect outgoing url's - reg exp

         

shahindastur

8:13 pm on Sep 8, 2005 (gmt 0)

10+ Year Member



Hi,

I need help writing a reg exp that rewrites urls that are links outside the domain.

Like say all links in yahoo.com going outside of yahoo would be go to the temp page first

re exp:

<a href="(not)www.yahoo.com/etc/etc"></a>
OR <a href='(not)www.yahoo.com/etc/etc'></a>
and replace with
<a href='www.goherefirst.com?addr=whatever.com/etc/etc'></a>

Any help would be greatly appreciated!

encyclo

12:47 am on Sep 11, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



When you mention regular expressions, do you mean that you are generating your pages and want to replace all external links to be replaced by a redirect script, or something else? What scripting language are you using?

shahindastur

2:03 am on Sep 11, 2005 (gmt 0)

10+ Year Member



Thanks for your reply.

ideally would like to find an apache module where the script could sit (not exactly sure) - write a perl script to find the external urls and translate accordingly.

otherwise include a php file that does the above in all our pages.