RewriteEngine    On

#REST api
RewriteRule ^(.*)/api/(.*)$                                                     $1/api/index.php?rewrite_uri=$2 [QSA]

# $mac or $mac.cfg/xml
RewriteRule     ^.*([A-Fa-f0-9]{12})(?:\.xml|\.cfg)?$                           app/provision/index.php?mac=$1 [QSA]

# $m:a:c or $m:a:c.cfg/xml
RewriteRule     ^.*((?:[A-Fa-f0-9]{2}[:-]){5}[A-Fa-f0-9]{2})(?:\.xml|\.cfg)?$   app/provision/index.php?mac=$1 [QSA]

# kt*-$mac.xml
RewriteRule     ^kt.*?-([A-Fa-f0-9]{12})\.xml$                                  app/provision/index.php?mac=$1 [QSA]

# cfg-$mac.xml
RewriteRule     ^.*cfg([A-Fa-f0-9]{12})\.xml$                                   app/provision/index.php?mac=$1 [QSA]

#Snom m3
RewriteRule     ^m3/settings/([A-Fa-f0-9]{12})(?:\.cfg)?$                       app/provision/index.php?mac=$1 [QSA]

#Grandstream
RewriteRule     ^.*/cfg([A-Fa-f0-9]{12})(?:\.xml|\.cfg)?$                       app/provision/?mac=$1 [QSA]

#Yealink and Polycom
RewriteRule     ^.*/([A-Fa-f0-9]{12})(?:\.xml|\.cfg)?$                          app/provision/index.php?mac=$1 [QSA]

#Polycom
RewriteRule     ^provision/000000000000.cfg$                                    app/provision/?mac=$1&file={$mac}.cfg [QSA]
RewriteRule     ^provision/features.cfg$                                        app/provision/?mac=$1&file=features.cfg [QSA]
RewriteRule     ^provision/([A-Fa-f0-9]{12})-sip.cfg$                           app/provision/?mac=$1&file=sip.cfg [QSA]
RewriteRule     ^provision/([A-Fa-f0-9]{12})-phone.cfg$                         app/provision/?mac=$1 [QSA]
RewriteRule     ^provision/([A-Fa-f0-9]{12})-registration.cfg$                  app/provision/?mac=$1&file={$mac}-registration.cfg [QSA]
RewriteRule     ^provision/([A-Fa-f0-9]{12})-site.cfg$                          app/provision/?mac=$1&file=site.cfg [QSA]
RewriteRule     ^provision/([A-Fa-f0-9]{12})-web.cfg$                           app/provision/?mac=$1&file=web.cfg [QSA]
RewriteRule     ^provision/([A-Fa-f0-9]{12})-directory.xml$                     app/provision/?mac=$1&file=directory.xml [QSA]

#Escene
RewriteRule     ^.*/([0-9]{1,11})_Extern.xml$                                   app/provision/?ext=$1&file={$mac}_extern.xml [QSA]
RewriteRule     ^.*/([0-9]{1,11})_Phonebook.xml$                                app/provision/?ext=$1&file={$mac}_phonebook.xml [QSA]

#Aastra
RewriteRule     ^provision/aastra.cfg$                                          app/provision/index.php?file=aastra.cfg [QSA]

Options -Indexes

#PHP settings
php_value upload_max_filesize   25M
php_value post_max_size         35M
php_value memory_limit          512M
