##
# phpMyFAQ rewrite rules for Zeus Webserver
#
# This Source Code Form is subject to the terms of the Mozilla Public License,
# v. 2.0. If a copy of the MPL was not distributed with this file, You can
# obtain one at http://mozilla.org/MPL/2.0/.
#
# @author    Chris Crawshaw <chris.crawshaw@expressware.co.ukt>
# @author    Thorsten Rinne <thorsten@phpmyfaq.de>
# @copyright 2012 phpMyFAQ Team
# @license   http://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0
# @link      http://www.phpmyfaq.de
# @since     2012-08-09

map path into SCRATCH:path from %{URL}

look for file at %{SCRATCH:path}

if exists then goto END

look for dir at %{SCRATCH:path}

if exists then goto END

match URL into $ with ^/template/.*$
if matched then goto END

match URL into $ with ^/admin/.*$
if matched then goto END

#start page
match URL into $ with ^/index\.html$
if matched set URL = /index.php

# show all categories
match URL into $ with ^/showcat\.html$
if matched then set URL = /index.php?action=show

# the search page
match URL into $ with ^/search\.html$
if matched then set URL = /index.php?action=search

# the add content page
match URL into $ with ^/addcontent\.html$
if matched then set URL = /index.php?action=add

# the ask question page
match URL into $ with ^/ask\.html$
if matched then set URL = /index.php?action=ask

# the open questions page
match URL into $ with ^/open\.html$
if matched then set URL = /index.php?action=open

# the help page
match URL into $ with ^/help\.html$
if matched then set URL = /index.php?action=help

# the contact page
match URL into $ with ^/contact\.html$
if matched then set URL = /index.php?action=contact

# the instant response page
match URL into $ with ^/instantresponse\.html$
if matched then set URL = /index.php?action=instantresponse

# a page with a record (backward compatibility)
match URL into $ with ^/([0-9]+)_([0-9]+)_([a-z\-]+)\.html$
if matched then set URL = /index.php?action=artikel&cat=$1&id=$2&artlang=$3

# a category page with page count (backward compatibility)
match URL into $ with ^/category([0-9]+)_([0-9]+)\.html$
if matched then set URL = /index.php?action=show&cat=$1&seite=$2

# a category page (backward compatibility)
match URL into $ with ^/category([0-9]+)\.html$
if matched then set URL = /index.php?action=show&cat=$1

# sitemap (backward compatibility)
match URL into $ with ^/sitemap-([a-zA-Z0-9]*)_([a-z\-]+)\.html$
if matched then set URL = /index.php?action=sitemap&letter=$1&lang=$2

# a solution id page
match URL into $ with ^/solution_id_([0-9]+)\.html$
if matched then set URL = /index.php?solution_id=$1

# PMF faq record page
match URL into $ with ^/content/([0-9]+)/([0-9]+)/([a-z\-]+)/(.+)\.htm(l?)$
if matched then set URL = /index.php?action=artikel&cat=$1&id=$2&artlang=$3

# PMF category page with page count
match URL into $ with ^/category/([0-9]+)/([0-9]+)/(.+)\.htm(l?)$
if matched then set URL = /index.php?action=show&cat=$1&seite=$2

# PMF category page
match URL into $ with ^/category/([0-9]+)/(.+)\.htm(l?)$
if matched then set URL = /index.php?action=show&cat=$1

# PMF news page
match URL into $ with ^/news/([0-9]+)/([a-z\-]+)/(.+)\.htm(l?)$
if matched then set URL = /index.php?action=news&newsid=$1&newslang=$2

# PMF sitemap
match URL into $ with ^/sitemap/([^\/]+)/([a-z\-]+)\.htm(l?)$
if matched then set URL = /index.php?action=sitemap&letter=$1&lang=$2

# PMF Google sitemap
match URL into $ with ^/sitemap.xml$
if matched then set URL = /sitemap.google.php

match URL into $ with ^/sitemap.gz$
if matched then set URL = /sitemap.google.php?gz=1

match URL into $ with ^/sitemap.xml.gz$
if matched then set URL = /sitemap.google.php?gz=1

# PMF tags page with page count
match URL into $ with ^/tags/([0-9]+)/([0-9]+)/(.+)\.htm(l?)$
if matched then set URL = /index.php?action=search&tagging_id=$1&seite=$2

# PMF tags page
match URL into $ with ^/tags/([0-9]+)/([^\/]+)\.htm(l?)$
if matched then set URL = /index.php?action=search&tagging_id=$1

# rest/json API
match URL into $ with ^/api/getVersion
if matched then set URL = /api.php?action=getVersion

match URL into $ with ^/api/getApiVersion
if matched then set URL = /api.php?action=getApiVersion

match URL into $ with ^/api/search/([a-z\-]+)/([a-z\-]+)$
if matched then set URL = /api.php?action=search&lang=$1&q=$2

match URL into $ with ^/api/getCategories
if matched then set URL = /api.php?action=getCategories

match URL into $ with ^/api/getFaqs/([a-z\-]+)/([0-9]+)
if matched then set URL = /api.php?action=getFaqs&lang=$1&categoryId=$2

match URL into $ with ^/api/getFaq/([a-z\-]+)/([0-9]+)
if matched then set URL = /api.php?action=getFaq&lang=$1&recordId=$2