There is a different approach if you want to keep compatibility with old API calls. For some obscure reason, my Apache server doesn't analyze the string ^api/...
during the rewrite parsing.
But you can still use http://www.somedomain.com/api/v2_soap?wsdl=1
without changing Magento PHP code. You just need to change the .htaccess like the following:
Replace in .htaccess:
RewriteRule ^api/([a-z][0-9a-z_]+)/?$ api.php?type=$1 [QSA,L]
by
RewriteRule ^api(\.php)?/([a-z][0-9a-z_]+)/?$ api.php?type=$2 [QSA,L]
(see the ^api.php/ instead of ^api/)
And even better if some of you, have http://www.somedomain.com/api/V2_soap?wsdl=1
(V2_soap is uppercase), you will have to add a RewriteMap
to use internal apache function to set in lowercase the parameter. Add to your virtual host the RewriteMap:
RewriteMap lc int:tolower
And in the .htaccess
RewriteRule ^api(\.php)?/([a-zA-Z][0-9a-z_]+)/?$ api.php?type=${lc:$2} [QSA,L]
This will set to lowercase the parameter for the api.php script and also accept 'V2_soap' in the regular expression
This last part has been brought by @dreeves in this answer