I have a PHP project that exposes its API under /api/public/(xyz)
. The http root directory has .htacces
s file that rewrites those requests to be processed by index.php
.
For reason not relevant here, we want to expoze (xyz) methods under /services(xyz)
.
My very naive approach was to create services
subdirectory and .htaccess
file with the following content:
RewriteEngine On
RewriteRule ^(.*)$ /api/public/$1 [PT]
My idea was, that request to /services/(xyz)
will be rewrited to /api/public/(xyz)
and handled internall as if the second URL was invoked. However, it doesn't seem to work. Apache logs 404 for the request.
What did I get wrong here?
Please note, it's not the problem with the rule syntax itself, I'm able to get static resource. The problem is, that after rewriting, I get the URL that would be rewrited by other rules, that are in the other file. How the rules are flowing through multiple files is something that is not covered by the canonical question...