Dispatcher RewriteCond is not working on Production(AEMCaaS) | Community
Skip to main content
mirza_akram
Level 2
October 3, 2022
Solved

Dispatcher RewriteCond is not working on Production(AEMCaaS)

  • October 3, 2022
  • 2 replies
  • 1281 views

I have a RewriteCond on prod as below

 

RewriteCond %{HTTP_HOST} ^www\.myprodsite\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/apps
RewriteCond %{REQUEST_URI} !^/bin
RewriteCond %{REQUEST_URI} !^/content
RewriteCond %{REQUEST_URI} !^/etc
RewriteCond %{REQUEST_URI} !^/home
RewriteCond %{REQUEST_URI} !^/libs
RewriteCond %{REQUEST_URI} !^/saml_login
RewriteCond %{REQUEST_URI} !^/system
RewriteCond %{REQUEST_URI} !^/tmp
RewriteCond %{REQUEST_URI} !^/var
RewriteRule ^/(.*)$ /content/mysite/$1.html [PT,L]

This Rule is not executed when I hit links like www.myprodsite.com/test 

If I keep everything same except the url in dev environment then it works fine as below

RewriteCond %{HTTP_HOST} ^mysite-dev\.adobecqms\.net$ [NC]

 Hence link like www.mysite-dev.adobecqms.net/test gets redirected to www.mysite-dev.adobecqms.net/content/mysite/test.html

Also other rules in the same prod file works fine. 

How can we check the logs for the dispatcher in Adobe AMS?

Do we have to do any changes on prod to allow any domain specific conditions?

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 tim_funk

This looks like a general mod_rewrite issue. On your dispatcher ... you'll want to turnout debugging in mod_rewrite and it'll log all checks above into a file. From there you'll see which rules pass as well as fail.  

 

ref: https://httpd.apache.org/docs/current/mod/mod_rewrite.html#logging

 

LogLevel alert rewrite:trace3
 
One other possibility is that the rewrite engine is off. I've accidently ran into that where the dev environment had it turned on, but production  in various virtual hosts had it never set (defaulted off)
RewriteEngine on

2 replies

tim_funk
tim_funkAccepted solution
Level 3
October 5, 2022

This looks like a general mod_rewrite issue. On your dispatcher ... you'll want to turnout debugging in mod_rewrite and it'll log all checks above into a file. From there you'll see which rules pass as well as fail.  

 

ref: https://httpd.apache.org/docs/current/mod/mod_rewrite.html#logging

 

LogLevel alert rewrite:trace3
 
One other possibility is that the rewrite engine is off. I've accidently ran into that where the dev environment had it turned on, but production  in various virtual hosts had it never set (defaulted off)
RewriteEngine on
aanchal-sikka
Community Advisor
Community Advisor
December 18, 2023

The mod_rewrite log levels are defined by the variable REWRITE_LOG_LEVEL in the file conf.d/variables/global.var.

It can be set to error, warn, info, debug and trace1 - trace8, with a default value of warn. To debug your RewriteRules, it is recommended to raise the log level to trace2.

For debugging puposes, you can set following in /conf.d/variable/global.vars

 

Define REWRITE_LOG_LEVEL trace2

 

 

To set the log level per environment, use the appropriate conditional branch in the global.var file, as described below:

Define REWRITE_LOG_LEVEL debug <IfDefine ENVIRONMENT_STAGE> ... Define REWRITE_LOG_LEVEL warn ... </IfDefine> <IfDefine ENVIRONMENT_PROD> ... Define REWRITE_LOG_LEVEL error ... </IfDefine>

 

https://experienceleague.adobe.com/docs/experience-manager-cloud-service/content/implementing/developing/logging.html?lang=en

Aanchal Sikka