Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I have Word Documents that I open from my Web pages that has several different http addresses on each word document. When someone clicks on the links in these Word Documents I need it to take them to just one web page which says "Under Construction".
On one Word Document it has:
http://mydomainname/directory/index.html
Another Word Document has:
http://mydomainname/another/first.html
Another Word Document has:
http://anotherdomain/directTwo/abc.html
Can I use Perl to make sure when someone clicks on each of these documents it goes to just ONE page which will say: Under Construction

"OT:" added to title by tye

Replies are listed 'Best First'.
Re: redirecting http in word docs
by derby (Abbot) on Jan 12, 2004 at 16:35 UTC
    Well ... that the link is in a word doc is immaterial. Yes, you can do this with perl (or a mod_perl handler), but the easiest way to do it is have the html pages just contain meta tags that will redirect you.

    <meta http-equiv="refresh" content="2;url=http://www.your.com/construc +tion.html">

    -derby

      All the https in the word documents are dead links so I need to redirect from the word doc. Please advise how I can do this in Perl?
        Could you please give more information. Do you want a perl client side solution (for example a script that you can run to change the word document to have different urls). Or do you want a server side solution so that when the link is selected a proper page is displayed? You really need to further refine what and where you want to happen.

        If it's server side. Just create the proper files with the meta tag stuff.

        <html> <body> <meta http-equiv="refresh" content="2;url=http://www.your.com/construction.html"> Redirecting to construction page! </body> </html>
        Of course you could also do some funky things like create a custom error handler and hook that into apache.

        Now if what you want is a client side solution where you actually need to modify the word doc - then I can't help you except to say you have a mixed up idea of where redirection happens. The only thing that happens in the word doc is an HTTP request is made - its up to the server to redirect. If you want to handle this on the client, you need to modify the doc and replace the bad URLs with good ones.

        -derby

Re: redirecting http in word docs
by maa (Pilgrim) on Jan 12, 2004 at 19:48 UTC

    Hi...

    You didn't tell us what server it was, so here are a couple of options, one Perl(ish) and one not...

    1. If you are running under apache, see if mod_rewrite is available - if so you need to ad a ReWriteRule into your .htaccess file... this can redirect one URI to another... just enter one rule per doc/target as needed - this saves the browser actually loading the docs.
    2. The Perl solution would be to use Win32::OLE to parse all of your documents looking at their Hyperlinks collections and selectively updting their targets.
    3. I'm sure IIS has some equivalent to mod_rewrite... but then again...

    You've really not given us enough info to go on... (server type? number of files?) and your replies have been surprisingly helpful :-) - if none of the above sound good then I respectfully suggest manually opening the files and editing the links...

    HTH - mark

      Thanks, I thought I could do the redirect on the client side Word Doc. I have IIS server on Windows 2000. I have about 5 files.

        Hi...

        To do this on IIS you should read the IIS manual on Technet... half way down the page you'll read.

        Redirect Wildcards

        You can use redirect wildcards to match any number of characters in the original URL. Open a directory's property sheet in IIS Manager, select the Home Directory, Virtual Directory, or Directory tab, click the A redirection to a URL option, and insert the wildcard character (*) in the Redirect to text box. Begin the destination URL with an asterisk (*) and a semicolon (;), and separate pairs of wildcard characters and destination URLs with a semicolon.

        For example, to redirect all requests for /Scripts/Filename.stm to a single file called Default.stm, and to redirect all requests for /Scripts/Filename.asp to a single file called Default.asp, type the following in the Redirect To text box for the /scripts virtual directory:

        *;Filename.stm;/Default.stm;Filename.asp;/Default.asp,

        HTH - Mark