php - APACHE mod_rewrite change variable name in query string -


I am trying to change a variable name in a query string, so it is usable by my PHP code.

The query gets a post from the external system, so I can not control that it is posting a variable name with one location in it. And it makes it impossible for me to use the PHP $ _ GET function.

Change me from variable% 20name to ? New1

and I need to convert variable 2 to new 2

Many variables have been passed in the query, but only these two need to be changed . ? Variable% 20name = abc and variable2 = xyz

need to end as

? New1 = abc and new2 = xyz

In addition, they will not be in this order and can be more variable

then? Variable% 20name = abc & blah = 123 & amp; Blah2 = 456 & amp; Variable 2 = xyz

? New1 = abc and new2 = xyz

or ? May end as new1 = abc & blah = 123 & amp; Blah2 = 456 & amp; New2 = xyz

Will be cured in any way!

Please pars me the query mod_rewrite

The string with mod_rewrite is a bit of a pain, it should be done with RewriteCond and later RewriteRule , possibly in the original query string in PHP It's easy to break manually.

The complete query string can be found in the $ _ SERVE (within PHP) ['QUERY_STRING'] .

You can divide it by using preg_split () or explosion () , before & amp; , then on = , to get the key / value added.


using the custom% 20cbid = 123 & amp; Blahblahblah & amp; Name = example as an example.

  $ params = array (); Foreign currency ($ cKey, $ cValue) = (explosion "(& amp;", $ _SERVER ['QUERY_STRING']) as $ cKeyValue) = explosion ('=', $ cKeyValue, 2); $ Paramaz [urlcode ($ cK)] = urdxide ($ c value); } // will result in: $ params = array ('custom cbid' => 123, 'blahblahblah' = & gt; NULL, 'name' => Example);    

Comments

Popular posts from this blog

qt - switch/case statement in C++ with a QString type -

python - sqlite3.OperationalError: near "REFERENCES": syntax error - foreign key creating -

Python's equivalent for Ruby's define_method? -