M
M
Misha72014-11-04 20:55:34
PHP
Misha7, 2014-11-04 20:55:34

How to pass get, post arrays through htaccess ? ?

How to make a redirect with the help of mod_rewrite with the transfer of $_GET and $_POST arrays. That is, the user form using mod_rewrite is redirected with the transfer of the post array

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Sergey, 2014-11-04
@Misha7

with post array passing

Read on Wikipedia what is HTTP and what is the request body. What you see in PHP under these superglobals $_SERVER/$_POST/$_GET/$_FILES etc. it's all thanks to such a wonderful thing as SAPI (Server Application Programming Interface). That is, chatty PHP takes your HTTP request (which it was given to process by WEB servers, the same Apache or nginx or someone else) and calls the corresponding SAPI. That is, if we have Apache mod_php, then everything is a little different there (there are many different SAPIs for PHP). If we have php-fpm, then we have the very request there, which was proxied to us by some nginx or the same Apache. This very SAPI takes the request headers and stuffs everything into super-global arrays. He takes the cookie header and stuffs it into $_COOKIE or sees that we have a POST request and it is marked as multipart/formdata and parses the request, picks out files and saves to disk fills $_POST/$_FILES arrays. Let's say if a dude sends a request with Content-Type: application/json (which is fashionably stylish for youth for mobile clients), then PHP SAPI will not be able to parse it and you will have to take the request body and parse it yourself.
Your script only works AFTER SAPI prepares everything. and htaccess only affects work before SAPI starts, so no POST arrays, etc. Only HTTP requests.
Redirects are much more interesting as they are the result of a request. I mean... he doesn't have a body. there is no way to save the request body (well, how ... yes ... but the client must also be able to do this and htaccess alone is not enough here), so when redirecting, saving and transferring the original data to a new url will no longer work. That is, it is possible, but I repeat - it must be implemented from two sides, and then it is not quite a redirect, but more like you are submitting the form with two requests. One - finds out where to send the form data, the second sends.
So it goes.

A
algebris, 2014-11-04
@algebris

read carefully mat. part beget.ru/art_htaccess
use google, feel free...

P
Puma Thailand, 2014-11-04
@opium

Do not redirect. do a rewrite or use mod_proxy or proxy_pass in nginx.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question