[SOLUTION] [Apache/IIS]: Preview not working after upgrade to 4.4.0

Hi everyone! I hope you’re all doing well.

I saw that some users reported an issue with the Xibo CMS 4.4.x preview, like in this post.:

I upgraded my CMS and noticed the same symptom.

I use IIS / custom installation, and I want to share how I resolved the issue here. It might be useful for other types of custom installations as well.

Symptom:

/preview/layout/preview/{layoutId}
Page not found

The layout editor opened normally, thumbnails were generated, but the layout/campaign preview stayed broken.

In my case, the root cause was the web server rewrite configuration.

Starting with Xibo 4.4.x, the preview has its own front controller:

/web/preview/index.php

So requests that start with:

/preview/

must be internally rewritten to:

preview/index.php

If the web server still rewrites everything to the main CMS entrypoint:

index.php

then the CMS receives the preview URL as a normal WEB route, and it returns “Page not found”.

Apache / custom web server rule

For Apache or custom installations, make sure the equivalent rewrite rule exists before the general catch-all rule:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} ^/preview/.*$
RewriteRule ^ preview/index.php [QSA,L]

The important part is that the rule should match only URLs starting with:

/preview/

Do not use a broad pattern like:

.*/preview/.*

because that can incorrectly catch routes such as:

/region/preview/{id}

and send them to the wrong front controller.

IIS example

For IIS, this rule fixed the issue for me.

It must be placed before the general rewrite rule to index.php:

<rule name="Xibo Preview" stopProcessing="true">
  <match url="^" ignoreCase="false" />
  <conditions logicalGrouping="MatchAll">
    <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
    <add input="{URL}" pattern="^/preview/.*$" ignoreCase="false" />
  </conditions>
  <action type="Rewrite" url="preview/index.php" appendQueryString="true" />
</rule>

I also had to allow the OPTIONS verb, because the preview entrypoint uses CORS/preflight handling:

<verbs allowUnlisted="false">
  <add verb="GET" allowed="true" />
  <add verb="POST" allowed="true" />
  <add verb="HEAD" allowed="true" />
  <add verb="PUT" allowed="true" />
  <add verb="DELETE" allowed="true" />
  <add verb="OPTIONS" allowed="true" />
</verbs>

After applying the rewrite rule and recycling the application pool, this URL started returning the preview bundle correctly:

https://your-cms-address/preview/layout/playerBundle

And layout/campaign preview started working again.

So, for custom installations upgraded from 4.3.x to 4.4.x, I would recommend checking whether the web server configuration was updated to include the new /preview/ rewrite rule.

Update 1: In order to make the Elements / HTML work on the preview, the header bellow must be removed:
Header set X-Frame-Options: “sameorigin”


Documentation suggestion

Hi @natasha ,

Could the “Xibo on a web server” documentation be updated for CMS 4.4.x custom IIS/Apache installations?

We found that layout/campaign preview can return “Page not found” after upgrading from 4.3.x to 4.4.x if the web server rewrite rules are not updated.

The documentation should probably mention that /preview/* requests must be rewritten to:

/web/preview/index.php

before the general catch-all rule to:

index.php

For IIS, the required rule is:

<rule name="Xibo Preview" stopProcessing="true">
  <match url="^" ignoreCase="false" />
  <conditions logicalGrouping="MatchAll">
    <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
    <add input="{URL}" pattern="^/preview/.*$" ignoreCase="false" />
  </conditions>
  <action type="Rewrite" url="preview/index.php" appendQueryString="true" />
</rule>

Also, the OPTIONS verb should be allowed because the preview entrypoint handles CORS/preflight requests.

Thanks!

The topic i’ts already the solution for this problem. Read it all :slight_smile:

Good morning, But with an installation with Docker, how do I apply this solution? Thank you.

Hi @jhuguetr The solution above it’s for custom install using IIS/Apache users only.

Other people in other threads resolved the issue using different solutions:

https://community.xibo.org.uk/t/preview-not-working-after-upgrade-to-4-4-0/37365/8

All of them (myself included) fixed it by reviewing their web server configurations—albeit in different ways.
But if I had to guess, I’d say your problem might be related to a configuration of that nature.