2

I'm using an apache HTTPD server as a front, and want to redirect certain urls to another server running locally.

For instance I want:

http://www.example.com/index.php to load the file located at /var/www/index.php http://www.example.com/products/*proxied to another local server & url, e.g. http://127.0.0.1:9000/

I'm trying to write a simple .htaccess file in the root www directory, but whenever I do this simple example, it gives me a File does not exist error in the httpd log:

.htaccess:

RewriteEngine On
RewriteRule ^test.html$ /index.php

I tried to lookup this error, but all the references online are out of date. For instance, mod_rewrite error: [client 127.0.0.1] File does not exist references httpd.conf which is no longer included with apache httpd.

Does anyone know why mod_rewrite isn't working? or how to write a redirect to another local server?

1 Answer 1

1

To reverse proxy, you need to use the P flag:

RewriteRule ^/?products/(.*)$ http://127.0.0.1:9000/$1 [L,P]

You need to have mod_proxy loaded for this to work, otherwise it'll redirect the browser instead.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.