RewriteEngine On

RewriteRule . - [E=isInternal:0]

RewriteCond %{REQUEST_URI} ^/NO_CONTENT.shtml
RewriteRule . - [E=isInternal:1]

RewriteCond %{REQUEST_URI} /(landing|storyTelling)/v([0-9]+)/([A-Za-z]+)/([A-Za-z]+)\/?$
RewriteRule . - [E=X_ADA_PRODTYPE:%1]

RewriteCond %{HTTP_HOST} actions\.(.*)$
RewriteRule . - [E=X_ADA_ORIGIN_HOST:%1]

RewriteCond %{HTTP:X_ADA_PROFILE} !^$
RewriteRule . - [E=X_ADA_PROFILE:%{HTTP:X_ADA_PROFILE}]

RewriteCond %{HTTP:X_ADA_PRODUCT} !^$
RewriteRule . - [E=X_ADA_PRODUCT:%{HTTP:X_ADA_PRODUCT}]

RewriteCond %{HTTP:X_ADA_PROFILETOKEN} !^$
RewriteRule . - [E=X_ADA_PROFILETOKEN:%{HTTP:X_ADA_PROFILETOKEN}]

RewriteCond %{HTTP:X-Forwarded-Proto} !^$
RewriteRule . - [E=HTTPS:%{HTTP:X-Forwarded-Proto}]

<IfModule mod_headers.c>
    Include ${ADA_ACTIONS_ROOT}/../config/apache/dist/actions-headers.conf
</IfModule> 

RewriteCond %{ENV:isInternal} 0
RewriteCond %{REQUEST_URI} ^/(landing|storyTelling)/v([0-9]+)/([A-Za-z]+)/([A-Za-z]+)\/?$
RewriteCond ${ADA_ACTIONS_ROOT}/%{ENV:X_ADA_PRODTYPE}/v%2/%3.php -f
RewriteRule ^/(landing|storyTelling)/v([0-9]+)/([A-Za-z]+)/([A-Za-z]+)\/?$ /%{ENV:X_ADA_PRODTYPE}/v%2/%3.php?f=$4 [E=cors:0,E=isInternal:1,QSA,L]

# /v1/actions/getDynamicParts       => /landing/v1/actions.php?f=getDynamicParts

RewriteCond %{REQUEST_URI} !^/cgi-bin/
RewriteCond %{ENV:isInternal} 0
RewriteCond %{REQUEST_URI} !^/(landing|storyTelling)/v([0-9]+)\/?
RewriteRule ^/?(.*)$ - [R=404,E=isInternal:1]

RewriteCond %{ENV:isInternal} 0
RewriteCond %{REQUEST_URI} ^/(landing|storyTelling)/v([0-9]+)/([A-Za-z]+)/([A-Za-z]+)\/?$
RewriteCond ${ADA_ACTIONS_ROOT}/%{ENV:X_ADA_PRODTYPE}/v%2/%3.php !-f
RewriteRule ^/?(.*)$ - [R=404,E=isInternal:1]

ErrorDocument 404 /NO_CONTENT.shtml
