# this assumes you installed in /phpmyfaq/
#   if that is not the case,
#   sed 's,/phpmyfaq/,,g' _nginx.conf

location / {
    index index.php;

    if (!-f $request_filename) {
        # show all categories
        rewrite ^/phpmyfaq/showcat.html$ /phpmyfaq/index.php?action=show last;

        # the search page
        rewrite ^/phpmyfaq/search.html$ /phpmyfaq/index.php?action=search last;

        # the add content page
        rewrite ^/phpmyfaq/addcontent.html$ /phpmyfaq/index.php?action=add last;

        # the ask question page
        rewrite ^/phpmyfaq/ask.html$ /phpmyfaq/index.php?action=ask last;

        # the open questions page
        rewrite ^/phpmyfaq/open.html$ /phpmyfaq/index.php?action=open last;

        # the help page
        rewrite ^/phpmyfaq/help.html$ /phpmyfaq/index.php?action=help last;

        # the contact page
        rewrite ^/phpmyfaq/contact.html$ /phpmyfaq/index.php?action=contact last;

        # a page with a record (backward compatibility)
        # * http://[...]/1_1_en.html
        rewrite ^/phpmyfaq/([0-9]+)_([0-9]+)_([a-z\-]+).html$ /phpmyfaq/index.php?action=artikel&cat=$1&id=$2&artlang=$3 last;

        # a category page with page count (backward compatibility)
        # * http://[...]/category1_1.html
        rewrite ^/phpmyfaq/category([0-9]+)_([0-9]+).html$ /phpmyfaq/index.php?action=show&cat=$1&seite=$2 last;

        # a category page (backward compatibility)
        # * http://[...]/category1.html
        rewrite ^/phpmyfaq/category([0-9]+).html$ /phpmyfaq/index.php?action=show&cat=$1 last;

        # start page
        rewrite ^/phpmyfaq/index.html$ /phpmyfaq/index.php last;

        # sitemap (backward compatibility)
        rewrite ^/phpmyfaq/sitemap-([a-zA-Z0-9]*)_([a-z\-]+).html$ /phpmyfaq/index.php?action=sitemap&letter=$1&lang=$2 last;

        # a solution id page
        rewrite ^/phpmyfaq/solution_id_([0-9]+).html$ /phpmyfaq/index.php?solution_id=$1 last;

        # PMF faq record page
        # * http://[...]/content/1/1/<LANGUAGE CODE>/<FAQ TOPIC>.htm
        # * http://[...]/content/1/1/<LANGUAGE CODE>/<FAQ TOPIC>.html
        rewrite content/([0-9]+)/([0-9]+)/([a-z\-]+)/(.+).html$ /phpmyfaq/index.php?action=artikel&cat=$1&id=$2&artlang=$3 last;

        # PMF category page with page count
        # * http://[...]/category/1/<PAGE NUMBER/<CATEGORY NAME>.htm
        # * http://[...]/category/1/<PAGE NUMBER/<CATEGORY NAME>.html
        rewrite category/([0-9]+)/([0-9]+)/(.+).html$ /phpmyfaq/index.php?action=show&cat=$1&seite=$2 last;

        # PMF category page
        # * http://[...]/category/1/<CATEGORY NAME>.htm
        # * http://[...]/category/1/<CATEGORY NAME>.html
        rewrite category/([0-9]+)/(.+).html$ /phpmyfaq/index.php?action=show&cat=$1 last;

        # PMF news page
        rewrite news/([0-9]+)/([a-z\-]+)/(.+).html$ /phpmyfaq/index.php?action=news&newsid=$1&newslang=$2 last;

        # PMF sitemap
        # * http://[...]/sitemap/<LETTER>/<LANGUAGE CODE>.htm
        # * http://[...]/sitemap/<LETTER>/<LANGUAGE CODE>.html
        rewrite sitemap/([^\/]+)/([a-z\-]+).htm(l?)$ /phpmyfaq/index.php?action=sitemap&letter=$1&lang=$2 last;

        # PMF Google sitemap
        # * http://[...]/sitemap.xml
        # * http://[...]/sitemap.gz
        # * http://[...]/sitemap.xml.gz
        rewrite sitemap.xml$ /phpmyfaq/sitemap.google.php last;
        rewrite sitemap.gz$ /phpmyfaq/sitemap.google.php?gz=1 last;
        rewrite sitemap.xml.gz$ /phpmyfaq/sitemap.google.php?gz=1 last;

        # PMF tags page with page count
        # * http://[...]/tags/<ID>/<PAGE NUMBER>/<HEADER>.htm
        rewrite tags/([0-9]+)/([0-9]+)/(.+).htm(l?)$ /phpmyfaq/index.php?action=search&tagging_id=$1&seite=$2 last;

        # PMF tags page
        # * http://[...]/tags/<ID>/<HEADER>.htm
        rewrite tags/([0-9]+)/([^\/]+).htm(l?)$ /phpmyfaq/index.php?action=search&tagging_id=$1 last;

        # the instant response page
        rewrite ^/phpmyfaq/instantresponse.html$ /phpmyfaq/index.php?action=instantresponse last;

        # rest/json API
        # * http://[...]/api/<ACTION>/<LANGUAGE CODE>/<...>
        rewrite api/getVersion /phpmyfaq/api.php?action=getVersion last;
        rewrite api/getApiVersion /phpmyfaq/api.php?action=getApiVersion last;
        rewrite api/search/([a-z\-]+)/([a-z\-]+)$ /phpmyfaq/api.php?action=search&lang=$1&q=$2 last;
        rewrite api/getCategories /phpmyfaq/api.php?action=getCategories last;
        rewrite api/getFaqs/([a-z\-]+)/([0-9]+) /phpmyfaq/api.php?action=getFaqs&lang=$1&categoryId=$2 last;
        rewrite api/getFaq/([a-z\-]+)/([0-9]+) /phpmyfaq/api.php?action=getFaq&lang=$1&recordId=$2 last;

        break;
    }
}
