When I was troubleshooting webwork + shibboleth integration, everything works fine except the wrong target URL for Shibboleth lazy session initialization generated by webwork shibboleth module. Webwork Shibboleth module uses perl CGI to get the URL of for redirecting target. The URL was always https://server/webwork2 instead of https://server/webwork2/COURSENAME, when I click on a course to login. I did some digging and found out that the SCRIPT_NAME was set to /webwork2 instead of /webwork2/COURSENAME.
The root of this problem is related to DocumentRoot was set incorrectly in apache config file. The DocumentRoot was set to /www_data/webwork2 where it should be /www_data. Another way to solve the problem is add Alias /webwork2 /www_data/webwork2 to map the path to correct local directory.