Options +ExecCGI
AddHandler cgi-script .py

# Enable "clean" URLs
RewriteEngine On
# Define the rewrite base
RewriteBase /public/arena
# Send requests without parameters to viewpoint.py
RewriteRule ^$                      viewpoint.py  [QSA,L]
# Send requests for index.html to viewpoint.py
#RewriteRule ^index\.htm             viewpoint.py [L]
#RewriteRule ^index\.html            viewpoint.py [L]

# If the file or directory exists, return it.  If the file or directory does NOT exist,
# but it has an extension (such as *.png), do not process it through viewpoint.py
RewriteCond %{REQUEST_FILENAME} -f                [OR]
RewriteCond %{REQUEST_FILENAME} -d                [OR]
RewriteCond %{REQUEST_FILENAME} \..*$
RewriteRule .? -                                  [L]

# If the request appears to be for a file (without an extension) or a directory that 
# does not exist, send it to viewpoint.py
RewriteRule ^/?(.+)/(.*)$        viewpoint.py?channel=$1&title=$2 [QSA,L]

# Otherwise, send requests to viewpoint.py, appending the query string part
RewriteRule (.+)                    viewpoint.py?channel=$1  [QSA,L]
#RewriteRule ^([A-Z0-9\xa0-\xff].*)$ viewpoint.py  [QSA,L]
