V
V
Vladimir2020-11-05 10:05:10
Nginx
Vladimir, 2020-11-05 10:05:10

How to redirect a directory to an identical subdomain directory while keeping post parameters and http request headers?

Hello.
There is a directory with request processing controllers /api/controllers/v1/*.php on the main domain.
How to make a redirect to a subdomain with exactly the same directory in nginx or htaccess while preserving the transmitted http headers and POST parameters?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton B, 2020-11-05
@bigton

location /api/controllers/v1 {
    rewrite ^/api/controllers/v1(.*)$ https://sub.domain.com/$1 redirect;
}

L
Lynn "Coffee Man", 2020-11-05
@Lynn

It's just a redirect. Standard 301/302 will change the request to GET. There are 307/308, but they only guarantee to keep the POST and the request body, not the headers.
Perhaps you need a reverse proxy:
https://nginx.org/ru/docs/http/ngx_http_proxy_modu...
https://httpd.apache.org/docs/2.4/mod/mod_proxy.ht...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question