2

Our users are trying to embed links to our site http://www.newsfixed.com/ in Word documents, and they are failing. Word for Mac seems to be very sensitive to server configuration and sometimes fails to load certain links. The same problem seems to happen for links to http://www.facebook.com/ and http://www.pinterest.com/ (but links to google, twitter, instagram etc are fine)

Steps to reproduce:

  1. Create a new Word for Mac document
  2. Type the following URLs into the document, and let Word turn them into hyperlinks:

    http://www.google.com/ http://www.facebook.com/ http://www.theguardian.com/ http://www.nytimes.com/ http://www.pinterest.com/ http://www.instagram.com/ http://www.twitter.com/

  3. Click on the links -- you will see that Google, the Guardian, New York Times, Instagram and Twitter will work, but Facebook and Pinterest (and my site www.newsfixed.com) will not. Word reports an error, "Unable to open http://www.pinterest.com/. Cannot locate the Internet server or proxy server.":

Word hyperlink error

It could somehow be related to https://stackoverflow.com/questions/17926225/microsoft-office-hyperlink-issues but I'm not sure how!

From looking at pinterest.com's HTTP response it seemed that it might be to do with serving a 302 temporary redirect to an HTTPS version rather than a 301 - which both my site and pinterest had in common. So I changed my server config and now return 301s, but it doesn't seem to make any difference.

I'm on an old version of Word for Mac -- 12.3.6. I've had reports that it also happens on newer versions of Word (but no version numbers, sorry). Apparently it's only started happening in the past week, could it have something to do with the SSL handshake and Heartbleed patches perhaps? (I of course regenerated my certificate this week)

The server is standard Apache 2.4 on Ubuntu, running Django app via mod_wsgi.

Thanks for any help,

Brendan.

1 Answer 1

3

Well, I managed to get it working...

It seems that Word doesn't like my SSL certificate (from RapidSSL/GeoTrust), even though it passes all checks on SSL checker sites (digicert sslshopper and more).

So I realised I would have to catch the Word user agent in my Apache HTTPD config:

RewriteEngine On
# catch MS Office clients and send them to an HTTP redirect page
BrowserMatchNoCase (word|excel|powerpoint|ms-office) browser=ms-office
RewriteCond %{ENV:browser} ms-office
RewriteRule ^/(?!ms\-office) http://%{HTTP_HOST}/ms-office?url=%{REQUEST_URI} [R=301,L]

# everyone else can go to the HTTPS site
RewriteCond %{HTTPS} off
RewriteCond %{ENV:browser} !ms-office
RewriteRule ^(?!ms\-office) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

ScriptAlias /ms-office /<path>/bin/msoffice-redirect.sh

where "msoffice-redirect.sh" is a simple Bash CGI script (!) performing a meta refresh to the secure page:

#!/bin/bash

URL=${QUERY_STRING//url=/}

echo "Content-type: text/html"
echo
echo "<html><head><meta http-equiv='refresh' content='0;url=https://www.newsfixed.com${URL}'/></head><body></body></html>"

So the flow is:

  1. Word makes request to http:// URL
  2. Apache detects the user agent, if it's Office, redirect to a script
  3. Because the page looks normal to Office, Word opens a browser pointing to the script output on the unsecure server, which is a simple HTML page containing a meta refresh tag
  4. The refresh switches the user to the HTTPS version, but as the SSL handshake is happening in the browser now that's not a problem

Yes it's a complete hack. I feel dirty. But it works. All the links in Word documents must be http:// though, https:// links fail, but at least we can include some links in our Word docs now.

I was inspired by the "fix Microsoft links" Ruby app which does the same thing in a Ruby server.

I hope this helps somebody avoid the pain I've gone through this weekend!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .