mark
mark

Reputation: 2063

Apache External Redirect 404

I am struggling to do a simple external redirect (a rewrite really, I don't want to send the user a 3xx response) from one machine to another for web traffic.

The following rule should transparently proxy requests from http://myserver.com/api/users/1 to http://jsonplaceholder.typicode.com/users/1 but instead, I only get 404 Not Found responses from Apache.

RewriteEngine on
RewriteRule   "^/api(.*)" "http://jsonplaceholder.typicode.com/$1" [R]

Upvotes: 1

Views: 74

Answers (1)

anubhava
anubhava

Reputation: 785376

  1. You need to have control over apache config to enable mod_proxy
  2. Remove R flag and use P for proxy.

Your rule will be:

RewriteRule ^/?api(.*)$ http://jsonplaceholder.typicode.com/$1 [P,L,NC]

Upvotes: 1

Related Questions