Expand my Community achievements bar.

SOLVED

Dispatcher RewriteCond is not working on Production(AEMCaaS)

Avatar

Level 2

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?

1 Accepted Solution

Avatar

Correct answer by
Level 4

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

View solution in original post

2 Replies

Avatar

Correct answer by
Level 4

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

Avatar

Community Advisor

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/develo...


Aanchal Sikka