This is an old revision of the document!


How to fix "an error occurred while processing this directive"?

After enabling LiteMage, the store shows “an error occurred while processing this directive”.

Try to locate if the store uses some page optimization plugin, which could be the source of the problem, as it change the html after LiteMage inject esi:include for hole punching. In the end, such optimization plugin can not be located.

A common cause is that something rewrite the URLs for ESI:include directives which breaks litemage. Need to turn of rewrite log and server debug log for it. If https is used for the store, make sure you enabled the rewrite log on both 80 and 443 virtual host.

You will need to add the following to the virtual host and restart web server.

RewriteLogLevel 9

Then enable LSWS debug log by the following command

ps -ef | grep litespeed

to check the child process PID. then

kill -USR2 <PID>

to enable debug log.

You will need to mv the old error log file to other name.

mv error_log error_log.bak1

then run a URL test from browser to trigger the error. then

mv error_log log2check

then turn off the debug log:

kill -USR2 <PID>

By investigating the debug log: vi log2check, some rewrite rules have redirect /litemage/esi, which break LiteMage.

Error log:
2017-05-11 20:57:23.959 [INFO] [108.162.219.111:32659#APVH_82.147.14.70:S-2#APVH_82.147.14.70:443_staging.somedomain.] 

[REWRITE] Cond: Match

'/litemage/esi/getBlock/t/cart/bi/cart_sidebar/h/D/extra/YToxOntzOjk6ImFqYXhibG9jayI7YjoxO30,/s/1/dp/em0141/dt/em0141_shoes' with pattern '(.*)/$', result: -1
2017-05-11 20:57:23.959 [INFO] [108.162.219.111:32659#APVH_82.147.14.70:S-2#APVH_82.147.14.70:443_staging.somedomain.] [REWRITE] Source URI: 
'litemage/esi/getBlock/t/cart/bi/cart_sidebar/h/D/extra/YToxOntzOjk6ImFqYXhibG9jayI7YjoxO30,/s/1/dp/em0141/dt/em0141_shoes/' => 
Result URI: 'http://staging.somedomain.co.uk/litemage/esi/getBlock/t/cart/bi/cart_sidebar/h/D/extra/YToxOntzOjk6ImFqYXhibG9jayI7YjoxO30,/s/1/dp/em0141/dt/em0141_shoes/'
2017-05-11 20:57:23.959 [INFO] [108.162.219.111:32659#APVH_82.147.14.70:S-2#APVH_82.147.14.70:443_staging.somedomain.] [REWRITE] Last Rule, stop!

Need to check .htaccess for those rules. Finally identified that the following rewrite rules break litemage ESI. The solution is add conditions to exclude /litemage/esi to those rules.

Faulty rewrite Rules:

## Custom Selesti rewrites
  #301 redirect if pagination is on page 1 in query string
  RewriteCond %{QUERY_STRING} p=1
  RewriteRule ^(.*)$ %{REQUEST_URI}? [R=301,L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_URI} !(\.gif|\.png|\.jpg|\.jpeg|\.css|\.js)$ [NC]
  RewriteCond %{HTTP:X-Requested-With} !=XMLHttpRequest
  RewriteCond %{HTTP:X-REQUESTED-WITH} !^(XMLHttpRequest)$
  RewriteCond %{REQUEST_URI} !(.*)/$
  RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1/ [L,R=301]
  RewriteCond %{REQUEST_URI} [A-Z]
  RewriteCond %{REQUEST_URI} !^/(media|skin|js|customer|checkout|sgps|ajaxcart|themeframework|wishlist|)/
  RewriteCond %{HTTP:X-Requested-With} !=XMLHttpRequest
  RewriteCond %{HTTP:X-REQUESTED-WITH} !^(XMLHttpRequest)$
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-l
  RewriteRule (.*) ${lc:$1} [R=301,L]

Solutions to exclue litemage URL from the rewrite. ## Custom Selesti rewrites

  #301 redirect if pagination is on page 1 in query string
  RewriteCond %{QUERY_STRING} p=1
  RewriteRule ^(.*)$ %{REQUEST_URI}? [R=301,L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_URI} !(\.gif|\.png|\.jpg|\.jpeg|\.css|\.js)$ [NC]
  RewriteCond %{REQUEST_URI} !litemage
  RewriteCond %{HTTP:X-Requested-With} !=XMLHttpRequest
  RewriteCond %{HTTP:X-REQUESTED-WITH} !^(XMLHttpRequest)$
  RewriteCond %{REQUEST_URI} !(.*)/$
  RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1/ [L,R=301]
  RewriteCond %{REQUEST_URI} [A-Z]
  RewriteCond %{REQUEST_URI} !^/(media|skin|js|customer|checkout|sgps|ajaxcart|themeframework|wishlist|)/
  RewriteCond %{REQUEST_URI} !litemage
  RewriteCond %{HTTP:X-Requested-With} !=XMLHttpRequest
  RewriteCond %{HTTP:X-REQUESTED-WITH} !^(XMLHttpRequest)$
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-l
  RewriteRule (.*) ${lc:$1} [R=301,L]

Problem Resolved. Error message gone.

  • Admin
  • Last modified: 2017/05/11 21:11
  • by Jackson Zhang