.htaccess
author Ed Morley <emorley@mozilla.com>
Sun, 29 Mar 2015 20:48:49 +0400
changeset 1517 44054a6338ae01fad01993503a3da94257049d38
parent 1516 73ad7a52c30e515418b0449c630b5d63e8e4bccf
child 1518 7a5a6eeaf0e03691f8d102cbfff445eaf6ef05ac
permissions -rw-r--r--
Bug 1148915 - Make htaccess comment clearer

# PHP directives set here won't apply when scripts are run from the
# command line (eg for prefetching), so any PHP directive edits made
# to this file should likely be made to php/config-cli.php too.

<IfModule mod_rewrite.c>
  # Redirects for TBPL end of life (bug 1054977).
  RewriteEngine On
  RewriteBase /

  # Exclude the cache directory from all other rules, so we can still
  # view cache/revision_info.txt & the data-import logs.
  RewriteRule ^cache(/.*)?$ - [L]

  # mcMerge is now on its own hosting, so redirect separately from TBPL:
  # eg: https://tbpl.mozilla.org/mcmerge/?cset=2a404169de2d&tree=mozilla-central
  RewriteRule ^mcmerge(/.*)?$ https://mcmerge.paas.allizom.org/ [R=302,L]

  # Redirecting doesn't make sense for calls to TBPL's backend, so let's
  # return 403 Forbidden, so API consumers hit a more obvious failure mode.
  RewriteRule ^php(/.*)?$ - [F,L]

  # TBPL used non-standard names for the trees, so we have to convert to the
  # canonical repo name used by Treeherder/everywhere else. These rules could
  # be simplified using RewriteMap to just convert many of the repo names to
  # lowercase (though there are exceptions) but it can't be used inside an
  # .htaccess, and it's not worth the hassle of having to get WebOps involved.
  # So we just handle the common trees and let the rest hit the catch-all.

  RewriteCond %{QUERY_STRING} ^(.*)tree=Mozilla-Inbound(.*)$
  RewriteRule ^(.*)$ $1?%1repo=mozilla-inbound%2

  RewriteCond %{QUERY_STRING} ^(.*)tree=B2g-Inbound(.*)$
  RewriteRule ^(.*)$ $1?%1repo=b2g-inbound%2

  RewriteCond %{QUERY_STRING} ^(.*)tree=Fx-Team(.*)$
  RewriteRule ^(.*)$ $1?%1repo=fx-team%2

  RewriteCond %{QUERY_STRING} ^(.*)tree=Try(.*)$
  RewriteRule ^(.*)$ $1?%1repo=try%2

  RewriteCond %{QUERY_STRING} ^(.*)tree=Mozilla-Aurora(.*)$
  RewriteRule ^(.*)$ $1?%1repo=mozilla-aurora%2

  RewriteCond %{QUERY_STRING} ^(.*)tree=Mozilla-Beta(.*)$
  RewriteRule ^(.*)$ $1?%1repo=mozilla-beta%2

  RewriteCond %{QUERY_STRING} ^(.*)tree=Mozilla-Release(.*)$
  RewriteRule ^(.*)$ $1?%1repo=mozilla-release%2

  RewriteCond %{QUERY_STRING} ^(.*)tree=Gaia-Try(.*)$
  RewriteRule ^(.*)$ $1?%1repo=gaia-try%2

  RewriteCond %{QUERY_STRING} ^(.*)tree=Thunderbird-Trunk(.*)$
  RewriteRule ^(.*)$ $1?%1repo=comm-central%2

  RewriteCond %{QUERY_STRING} ^(.*)tree=Thunderbird-Try(.*)$
  RewriteRule ^(.*)$ $1?%1repo=try-comm-central%2

  RewriteCond %{QUERY_STRING} ^(.*)tree=Thunderbird-Aurora(.*)$
  RewriteRule ^(.*)$ $1?%1repo=comm-aurora%2

  RewriteCond %{QUERY_STRING} ^(.*)tree=Thunderbird-Beta(.*)$
  RewriteRule ^(.*)$ $1?%1repo=comm-beta%2

  RewriteCond %{QUERY_STRING} ^(.*)tree=Jetpack(.*)$
  RewriteRule ^(.*)$ $1?%1repo=addon-sdk%2

  # Next problem: Treeherder's query params are different in virtually all cases.
  # The repo name mappings above have already converted 'tree' to 'repo', but we
  # still have to handle pusher/rev. Any other params will be discarded for
  # simplicity. In addition, if the params are specified in an order different to
  # the one used by the UI, we don't match and so hit the catch-all, but it's not
  # worth the added complexity to handle this, since it should be rare.
  # The [NE] flag is required to prevent Apache escaping the '#' to '%23'.

  # Filtered by pusher:
  # eg: https://tbpl.mozilla.org/?tree=Try&pusher=email@mozilla.com
  # Any params other than the repo and pusher are discarded.
  RewriteCond %{QUERY_STRING} repo=([^&]+).*&pusher=([^&]+)
  RewriteRule ^(.*)$ https://treeherder.mozilla.org/#/jobs?repo=%1&author=%2 [NE,R=302,L]

  # Viewing a specific revision:
  # eg: https://tbpl.mozilla.org/?tree=Try&rev=cc63db12dafb
  # Any params other than the repo and revision are discarded.
  RewriteCond %{QUERY_STRING} repo=([^&]+).*&rev=([^&]+)
  RewriteRule ^(.*)$ https://treeherder.mozilla.org/#/jobs?repo=%1&revision=%2 [NE,R=302,L]

  # The standard view for a repo:
  # eg: https://tbpl.mozilla.org/?tree=Mozilla-Inbound
  # Any params other than the repo are discarded.
  RewriteCond %{QUERY_STRING} repo=([^&]+)
  RewriteRule ^(.*)$ https://treeherder.mozilla.org/#/jobs?repo=%1 [NE,R=302,L]

  # For everything else just redirect with the entire query string discarded.
  RewriteRule ^(.*)$ https://treeherder.mozilla.org/? [R=302,L]
</IfModule>

<IfModule mod_expires.c>
  ExpiresActive on
  ExpiresDefault "access plus 15 minutes"
</IfModule>

# Display errors in addition to logging them
# (disabled in production, change for dev environments)
php_flag display_startup_errors Off
php_flag display_errors Off

# Error logging
php_flag log_errors Off
php_value error_log "../logs/php_errors.log"

# Include all types of errors
php_value error_reporting -1

# Enable html markup of errors
php_flag html_errors On

# Parsing logs needs lots of memory, so be generous
php_value memory_limit 2048M

# It also can take a long time, so allow for 10 minutes
php_value max_execution_time 600