Agavi Routing Input Test Case Generator
=======================================
This script can be used to make test cases for web servers, rewrite engines etc. and various combinations of request paths, query strings and so forth.
These test cases can then be used in Agavi to make sure the routing is compatible with the web server in question.

To use it, put testcase.php into a directory on your web server, call it index.php, set up index.php as a directory index script, and run it once with, and once without rewrites enabled.
You need to click the appropriate button, of course, and you need to switch off rewrites in the server for the "norewrite" run - clicking the button is not enough.

The script will automatically gather data in various steps, and at the end of the run, it will present you with a PHP file for download that contains a complete routing test data set. You can submit this to a developer asking you for it.

Usually, you will be asked to run this four times:
- on the document root, with rewrites
- on the document root, without rewrites
- in a subdirectory, with rewrites
- in a subdirectory, without rewrites


Apache Rewrite Rules (.htaccess)
--------------------------------
DirectoryIndex index.php
Options -MultiViews -Indexes +FollowSymLinks

# For Apache2 without rewrites, so /index.php/foobar works.
AcceptPathInfo On

<IfModule mod_rewrite.c>
	RewriteEngine On
	# ********** THIS IS THE ONLY SETTING YOU SHOULD HAVE TO CHANGE **********
	# e.g. RewriteBase /~dzuelke/Code/oss/agavi/branches/1.0/etc/routing/test-case-generator/
	RewriteBase /PATH/IN/URL/TO/etc/routing/test-case-generator/
	
	# Special rule for calls to index.php so it can't be called directly, also prevents an infinite loop.
	# Redirect target *must* be "./index.php" or else mod_rewrite thinks the URL is the same and skips.
	# The check on REDIRECT_STATUS makes sure it's a direct request and not an internal redirect.
	# "NC" flag is for case insensitivity on OS X and Windows.
	RewriteCond %{ENV:REDIRECT_STATUS} ^$
	RewriteRule ^index.php.*$ ./index.php?/$0 [NC,QSA,L]
	# If the requested URL doesn't exist, let Agavi handle it
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteRule (.*) index.php?/$1 [QSA,L]
</IfModule>


Apache Rewrite Rules (vhost config)
-----------------------------------
# if requested url does not exist (i.e. it's likely an agavi route), pass it as path info to index.php
RewriteRule ^/$ /URL/PATH/TO/index.php?/ [QSA,L]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d
RewriteRule ^/(.*)$ /URL/PATH/TO/index.php?/$1 [QSA,L]
</IfModule>


lighttpd Rewrite Rules
----------------------
url.rewrite-once = ( 
  "^/~dzuelke/Code/oss/agavi/branches/1.0/etc/routing/([^?]*)(?:\?(.*))?$" => "/~dzuelke/Code/oss/agavi/branches/1.0/etc/routing/index.php?/$1&$2"
)


nginx Rewrite Rules
-------------------
rewrite ^/([^?]*)$ /index.php?/$1 last;


Microsoft IIS7 Rewrite Rules (URL Rewrite Module 2.0)
-----------------------------------------------------
<configuration>
  <system.webServer>
    <security>
      <requestFiltering allowDoubleEscaping="true" />
    </security>
    <rewrite>
      <rules>
        <rule name="Agavi Dispatcher for /" stopProcessing="true">
          <match url="^$" />
          <action type="Rewrite" url="index.php?/" />
        </rule>
        <rule name="Agavi Dispatcher" stopProcessing="true">
          <match url="^(.*)$" />
          <conditions logicalGrouping="MatchAll">
                <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
          </conditions>
          <action type="Rewrite" url="index.php?/{R:1}" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>


Microsoft IIS + ISAPIRewrite Rules
----------------------------------
UriMatchPrefix /users/cbrown/projects/win-a-baseball-match/pub/
UriFormatPrefix /users/cbrown/projects/win-a-baseball-match/pub/
RewriteRule ([^?]*)(?:\?(.*))? index.php?/$1&$2 [L]
