Results tagged “php”

Piwik generates its URLs used in links and forms based on data in $_SERVER[]. If you are using a reverse proxy in front of your web server, the incoming request URLS are for the internal server. This results in the people from the outside getting 404 errors after the getting the initial landing page.

To work around this, I was able to use Piwik's boostrap.php file. This is loaded first for any Piwik page. I added some code in there to rewrite PHP's $_SERVER[] parameters to match the original request to the proxy. The variables I had to set were


  • $_SERVER['HTTP_HOST']

  • $_SERVER['PHP_SELF']

  • $_SERVER['SCRIPT_NAME']

  • $_SERVER['REQUEST_URI']

Someone at work mentioned that Outlook was complaining about an RSS feed. The error message was "The link may not point to a valid RSS source". This was odd because the feed validated and every other feed reader was able to handle it. Even stranger, Outlook had no issues with the same feed if it was not coming from an https address.

After some experimentation, I tracked the problem down to caching. The feed was being generated by a PHP application that was using sessions. By default, PHP sets some http headers to prevent pages from being cached when sessions are used. Outlook 2007 could not handle an RSS feed coming from a server using SSL with caching requested off. The solution was to either turn off session handling when the request was for an RSS feed or change the headers before sent so that caching wasn't turned off. For this application doing the latter was easier.

1
Close