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]+)\/?$
RewriteRule . - [E=X_ADA_PRODTYPE:%1]

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

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

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

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

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

ErrorDocument 404 /NO_CONTENT.shtml
