0

I have a PHP project that exposes its API under /api/public/(xyz). The http root directory has .htaccess 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...

  • @JennyD Thank you for the link, it is nicely written documentation, but it still gives me now idea how are the rules from multiple files (like in my case) chained... – 9ilsdx 9rvj 0lo Feb 18 '19 at 16:12
  • Is it Apache generating the 404, or your API? There are some oddities with the way you are doing this, but it should still "work". Please post the `.htaccess` file from the document root (that ultimately routes the request to `index.php`). Do you have any other `.htaccess` files? – MrWhite Feb 18 '19 at 17:41
  • 1
    It does, however, tell you how to turn on debug output, which is how you find what happens. – Jenny D Feb 18 '19 at 17:49

0 Answers0