Dispatcher Redirecting request for fonts to 404 error pages | Community
Skip to main content
Rohan_Garg
Community Advisor
Community Advisor
August 12, 2022
Solved

Dispatcher Redirecting request for fonts to 404 error pages

  • August 12, 2022
  • 2 replies
  • 2456 views

Hi All,

 

I have the below scenario - 

 

1. CSS clientlibs file calling font files via url syntax as below - 

@2375939-face{
font-family:icomoon;
src:url(clientlib-site/resources/icons/icomoon.eot?s69qo9);
src:url(clientlib-site/resources/icons/icomoon.eot?s69qo9#iefix) format("embedded-opentype"),
url(clientlib-site/resources/icons/icomoon.ttf?s69qo9) format("truetype"),
url(clientlib-site/resources/icons/icomoon.woff?s69qo9) format("woff"),
url(clientlib-site/resources/icons/icomoon.svg?s69qo9#icomoon) format("svg");

}

 

2. Behavior on Publish and Dispatcher - 

Publish - The clientlibs and the files (ttf | woff) are displaying 200 OK when hit.

Dispatcher - The clientlibs file is correctly hit but the icon files are redirecting to 404 pages.

 

Fixes Tried - 

1. Updated the VHost configuration to turn on ModMimeUsePathInfo.

ModMimeUsePathInfo On 
<IfModule mod_mime.c>
AddType application/vnd.ms-fontobject .eot
AddType application/x-font-opentype .otf
AddType image/svg+xml .svg
AddType application/x-font-ttf .ttf
AddType application/font-woff .woff
AddType application/font-woff2 .woff2
</IfModule>

 

Can you please help why the dispatcher would redirect the font request to error page with 301 ?

The other clientlibs request for CSS and JS are loading fine, the publisher is downloading the font icon when directly hit.

@gaurav-behl , @achennapragada , @arunpatidar , @mohit_kbansal , @kautuk_sahni 

 

Please find the dispatcher logs below - 

HTTPD Access Logs
cm-pxxxxx-exxxxxx-aem-publish-zzzzzzzzz-yyyyy - - 12/Aug/2022:14:12:12 +0000 "GET /etc.clientlibs/brandA/clientlibs/clientlib-site/resources/icons/icomoon.ttf?s69qo9 HTTP/1.1" 301 245 "https://brandA.com/etc.clientlibs/brandA/clientlibs/clientlib-site.lc-4475042b57b4e02f2f8147fe0b49fb14-lc.min.css" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36"


cm-pxxxxx-exxxxxx-aem-publish-zzzzzzzzz-yyyyy - - 12/Aug/2022:14:12:13 +0000 "GET /etc.clientlibs/brandA/clientlibs/clientlib-site/resources/icons/icomoon.woff?s69qo9 HTTP/1.1" 301 245 "https://brandA.com/etc.clientlibs/brandA/clientlibs/clientlib-site.lc-4475042b57b4e02f2f8147fe0b49fb14-lc.min.css" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36"


cm-pxxxxx-exxxxxx-aem-publish-zzzzzzzzz-yyyyy - - 12/Aug/2022:14:25:36 +0000 "GET /etc.clientlibs/brandA/clientlibs/clientlib-site/resources/icons/icomoon.ttf?s69qo9 HTTP/1.1" 301 245 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36"

 

Request Logs - Directly Hitting Publish
14/Aug/2022:08:46:54 +0000 [45925] -> GET /etc.clientlibs/brandA/clientlibs/clientlib-site/resources/icons/icomoon.ttf?s69qo9 HTTP/1.1 [cm-p57852-e459121-aem-publish-5498f7f4d9-rxms2]
14/Aug/2022:08:46:54 +0000 [45925] <- 200 application/x-font-ttf 9ms [cm-p57852-e459121-aem-publish-5498f7f4d9-rxms2]

 

Request Logs - When hitting same URL on dispatcher
14/Aug/2022:08:10:09 +0000 [41611] -> GET /etc.clientlibs/brandA/clientlibs/clientlib-site/resources/icons/icomoon.ttf?s69qo9 HTTP/1.1 [cm-p57852-e459121-aem-publish-5498f7f4d9-rxms2]
14/Aug/2022:08:10:09 +0000 [41611] <- 404 - 12ms [cm-p57852-e459121-aem-publish-5498f7f4d9-rxms2]

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Rohan_Garg

Hi All,

 

The problem is now resolved.

 

Checking the Publish's Error Log I found the issue below - 

14.08.2022 08:10:09.651 [cm-pxyxyx-eyyyyyy-aem-publish-54abcdefd9-rxms2] *INFO* [122.177.105.119 [1660464609650] GET /etc.clientlibs/brandA/clientlibs/clientlib-site/resources/icons/icomoon.ttf HTTP/1.1] com.adobe.granite.ui.clientlibs.impl.ClientLibraryProxyServlet Proxy request to /etc.clientlibs/brandA/clientlibs/clientlib-site/resources/icons/icomoon.ttf not supported.

 

The sling mapping for etc.clientlibs was missing in dispatcher which solved the issue.

2 replies

Level 2
August 12, 2022

Hi @rohan_garg ,

I believe it must be issue with rewrites. Can you please share the full path of the sample file (e.g. icomoon.ttf)

Rohan_Garg
Community Advisor
Community Advisor
August 12, 2022
Rohan_Garg
Community Advisor
Community Advisor
August 14, 2022

Please find below the sample rewrite (for testing). The below rewrite would be applicable to shortened urls and ends with only .html extension

 

#Redirect for all the shortened pages with html

RewriteCond %{REQUEST_URI} !^/?(etc.clientlibs|resources|libs|content|libs|apps) [NC]

RewriteCond %{REQUEST_URI} ^/(.*).html$

RewriteRule ^/(.*) /content/<projectname>/us/en/$1 [PT,L,QSA]


I tested on the https://technicalseo.com/tools/htaccess/ all my rewrite rules to see if any can interfere with my request URL - none of them is passing the rewrite conditions or passing the rewrite rule criteria.

Request URL - https://domainA.com/etc.clientlibs/domainA/clientlibs/clientlib-site/resources/icons/icomoon.woff?s69qo9

The initiator for this resource is a clientlib min.css file which is being handled by dispatcher correctly - 

https://domainA.com/etc.clientlibs/domainA/clientlibs/clientlib-site.lc-4474712b67b4e02f2f4673fe0b49fb14-lc.min.css

 

All Rewrite Rules in sequence - 

1. # Add .html extension when extension is missing from request
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^.]*[^./])$ https://%{SERVER_NAME}$1.html [R=301,L]

 

2. #Rewrite for Root Direction

RewriteRule "^(/?)$" "/content/brandA/us/en/home.html" [PT,L]

 

3. Rewrite for URL Shortening

RewriteCond %{REQUEST_URI} !^/apps
RewriteCond %{REQUEST_URI} !^/bin
#RewriteCond %{REQUEST_URI} !^/content
RewriteCond %{REQUEST_URI} !^/etc
RewriteCond %{REQUEST_URI} !^/libs
RewriteCond %{REQUEST_URI} !^/saml_login
RewriteCond %{REQUEST_URI} !^/system
RewriteCond %{REQUEST_URI} !^/tmp
RewriteCond %{REQUEST_URI} !^/var
RewriteCond %{REQUEST_URI} (.html|.jpe?g|.png|.svg|.xml)$
#RewriteRule ^/content/brandA/us/en/(.*)$ /$1 [NE,L,R=301]
RewriteRule ^/content/brandA/us/en/(.*)(\.html)?$ https://%{SERVER_NAME}/$1 [NE,L,R=301]

 

4. #Replace the .html with /
RewriteCond %{REQUEST_URI} \.html$
RewriteRule ^/(.*).html$ https://%{SERVER_NAME}/$1/ [R=301,L,QSA]

 

5. #Append the .html for those URL’s ending with / before sending to publisher
#This rule should not work for requests originating with non /content/brandA domains and should also work for shortened URLs
RewriteCond %{REQUEST_URI} !^/content/brandB
RewriteCond %{REQUEST_URI} !^/$
RewriteRule ^/(.*)/$ /content/brandA/us/en/$1.html [PT,L,QSA]

 

6. RewriteCond %{REQUEST_URI} !^/apps
RewriteCond %{REQUEST_URI} !^/bin
RewriteCond %{REQUEST_URI} !^/content
RewriteCond %{REQUEST_URI} !^/etc
RewriteCond %{REQUEST_URI} !^/libs
RewriteCond %{REQUEST_URI} !^/saml_login
RewriteCond %{REQUEST_URI} !^/system
RewriteCond %{REQUEST_URI} !^/tmp
RewriteCond %{REQUEST_URI} !^/var
RewriteCond %{REQUEST_URI} (.html|.jpe?g|.png|.svg)$
RewriteRule ^/(.*)$ /content/brandA/us/en/$1 [NC,PT,L]

Rohan_Garg
Community Advisor
Rohan_GargCommunity AdvisorAuthorAccepted solution
Community Advisor
August 14, 2022

Hi All,

 

The problem is now resolved.

 

Checking the Publish's Error Log I found the issue below - 

14.08.2022 08:10:09.651 [cm-pxyxyx-eyyyyyy-aem-publish-54abcdefd9-rxms2] *INFO* [122.177.105.119 [1660464609650] GET /etc.clientlibs/brandA/clientlibs/clientlib-site/resources/icons/icomoon.ttf HTTP/1.1] com.adobe.granite.ui.clientlibs.impl.ClientLibraryProxyServlet Proxy request to /etc.clientlibs/brandA/clientlibs/clientlib-site/resources/icons/icomoon.ttf not supported.

 

The sling mapping for etc.clientlibs was missing in dispatcher which solved the issue.