PHP - .htaccess Re-Write for external server connections

Viewed 87

I have multiple servers and a main server hosting my API.

[Server 1] <---> [API Server]
[Server 2] <---> [API Server]

I am having a bit of struggle actually sending the curl request to the API server and am unsure if its possible from external servers. I read up an article about using a redirect so the server acts like its internal (CORS).

The URL needed is (where the API file is located):

$this->url = "http://www.example.com/API/RequestsDJ/API/RequestsHandler.php";

However, I am struggling with writing the .htaccess file, so far I have:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule API/RequestsDJ/(.*)$ API/RequestsDJ/API/RequestsHandler.php [QSA,NC,L]
</IfModule>

The idea here is to convert the URL to:

$this->url = "http://www.example.com/API/RequestsDJ";

Which is then, through the CORS method, redirected as an internal request which then runs the functions inside the: API/RequestsDJ/API/RequestsHandler.php file. (I am not sure also if this will carry the POST data with it but for now, its just for testing).

Could anyone give me a hand? Thanks in advance, I suck at .htaccess files (the API doesn't support any GET requests, so any ?example= is not needed).

1 Answers
Related