Troubleshooting subfolder integration issues

Setting up a subdomain integration can be fairly straightforward. However, setting up a subfolder configuration instead can be a little trickier, as there are different web servers and they can be configured in numerous ways. This article aims to provide some troubleshooting steps in case the subfolder integration is not set up correctly.

Table of contents:

What to look for:

To find out if the subfolder configuration is working, check the following:

  1. Is the newsroom homepage showing?
  2. Do the links to the individual articles work?
  3. Does the Search module work?
  4. Does the Download module work? It should trigger a direct download of the attached file.
  5. Does the downwards arrow (see image below) beneath the Headlines module work? It should load the remaining articles that are part of that headlines module.
    arrow.png

If you cannot answer all above questions with 'yes', you may be dealing with a subfolder config issue.

What a default subfolder configuration code snippet looks like:

Apache:

SSLProxyEngine on

<Location "/subfolder-example">
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^.*/subfolder-example(.*)? https://client.presspage.com/$1?subfolder=1&clienthash=12e687a8eb2f0ee0ce7e30ff2b2bb1db&trail=%{REQUEST_URI} [QSA,L,P]
</IfModule>
</Location>

IIS:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Presspage Newsroom" stopProcessing="true">
<match url="^subfolder-example(.*)" />
<serverVariables>
<set name="HTTP_X_FORWARDED_HOST" value="www.example.com" />
</serverVariables>
<action type="Rewrite" url="http://client.presspage.com/{R:1}?subfolder=1&amp;clienthash=12e687a8eb2f0ee0ce7e30ff2b2bb1db&amp;trail=/{R:1}" logRewrittenUrl="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>

Nginx:

location /subfolder-example {
resolver 8.8.8.8;
rewrite ^/subfolder-example/(.*) /$1 break;
proxy_pass https://client.presspage.com$uri?subfolder=1&clienthash=12e687a8eb2f0ee0ce7e30ff2b2bb1db&trail=$uri&$args;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host www.example.com;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass_request_headers on;
}

Caution:

Please note that the clienthash is different for every account and should NOT be copied to your configuration from this Knowledge Base page.

If you're using a CDN, please make sure that it passes the IP address of the client to the origin, rather than the IP address of the CDN itself.

What does this snippet do?

It does three things:

  1. It uses a regular expression to make sure that the rule only applies to URLs that start with the subfolder of the domain, plus any (including zero) characters that come after it. These characters are saved as a regex match ($1 or R:1 in the snippets above).
  2. If the rule can be applied, an X-Forwarded-Host header is set. The value of this header is the domain name itself, without the subfolder. It should match the domain name as configured by Presspage in the Presspage backend. 
  3. It will then rewrite the URL of the request to the client.presspage.com URL as seen in the snippet, and insert the regex match where appropriate.

Without a correctly configured X-Forwarded-Host header, the correct page cannot be returned.

Most frequent issues:

Query string parameters

One thing that we see quite often is that requests with query string parameters in them will not actually hit the Presspage servers, which causes the problems with the Search, Download and Headline Modules. 

If you have a Web Application Firewall (WAF) or a CDN such as Akamai, Cloudflare or AWS Cloudfront in place, make sure that these requests do not get filtered out. Query strings should be forwarded to the origin.

Make sure that caching on your end is not interfering with this.

Other conflicting rulesets

Another thing to check is to make sure that you don't have any other configuration rules in direct conflict with the snippet supplied by us. Have a look if an exception can be made, or if the snippet can be moved to the beginning of the file to make sure it gets executed first.

Also make sure that there is not another application with rulesets of its own conflicting with the snippet.

If you're using Sitecore, make sure to add the newsroom subfolder to the "Ignore URL prefix list".

Include all configuration lines

Finally, make sure that all configuration lines have been included, and that the regex in the rule is correct.

Was this article helpful?
0 out of 0 found this helpful