RewriteEngine On

# These rules are disabled so our site specific ReWrite rules will work,
# these are located in site-misc-directives.
# This rule is meant for autotest installations under a single directory,
# such as when pulling the code from git or from a tarball.
# RewriteCond /usr/local/autotest/results -d
# RewriteRule ^/results(.*) /usr/local/autotest/results/$1

# This rule is meant for autotest installations from a package such as RPM.
# RewriteCond /var/lib/autotest/results -d
# RewriteRule ^/results(.*) /var/lib/autotest/results/$1

Alias /results "/usr/local/autotest/results"
<Location "/results">
    IndexHeadInsert "<img src='/afe/header.png'/><hr/>"
    Options +Indexes +FollowSymLinks +MultiViews
    <IfVersion >= 2.4>
        Require all granted
    </IfVersion>
    <IfVersion <= 2.2.99>
        Order allow,deny
        Allow from all
    </IfVersion>
</Location>

<LocationMatch "/results.*\.(log|DEBUG|INFO|WARNING|ERROR)$">
    ForceType "text/plain; authoritative=true"
</LocationMatch>

# This rule is meant for autotest installations under a single directory,
# such as when pulling the code from git or from a tarball.
RewriteCond /usr/local/autotest/tko -d
RewriteRule ^/tko(.*) /usr/local/autotest/tko/$1

# These rules serve the tko interface when installed together with autotest
# libraries on python site-packages. Covers python versions 2.4 through 2.7.
RewriteCond /usr/lib/python2.7/site-packages/autotest/tko -d
RewriteRule ^/tko(.*) /usr/lib/python2.7/site-packages/autotest/tko/$1

RewriteCond /usr/lib/python2.6/site-packages/autotest/tko -d
RewriteRule ^/tko(.*) /usr/lib/python2.6/site-packages/autotest/tko/$1

RewriteCond /usr/lib/python2.5/site-packages/autotest/tko -d
RewriteRule ^/tko(.*) /usr/lib/python2.5/site-packages/autotest/tko/$1

RewriteCond /usr/lib/python2.4/site-packages/autotest/tko -d
RewriteRule ^/tko(.*) /usr/lib/python2.4/site-packages/autotest/tko/$1

<Location "/tko">
    Options +ExecCGI +Indexes +MultiViews +SymLinksIfOwnerMatch
    DirectoryIndex compose_query.cgi
    <IfVersion >= 2.4>
        Require all granted
    </IfVersion>
    # Non existing version, safeguard against new 2.2 releases
    <IfVersion <= 2.2.99>
        Order allow,deny
        Allow from all
    </IfVersion>
</Location>