apache - .htaccess - need to replace "?" in URL with "&" -


so, have url unfortunately cannot modified, , paypal checkout appends token "?token=.....". problem proxy url contains several parameters, paypal token must appended "&token=.....", otherwise "token" not visible query string var.

the way think might work replace "?" "&" in .htaccess file. ( unless has better idea! )

url including paypal token:
https://some.samplesite.com/proxy/091f126b7b6d624623606a1bb67edc430885abaf02ad5975ff2a8276e21fd083091f126b7b6d624623606a1bb67edc430151c3df14a66603f9389b45ec89c9057c76a20ea0b4746ba97d7027e67e9ebc6437dcca31b42521a4794f8e766ab37a76c0e6bd4fc92c60351e7c5fadb37cf0f82210a04bf29a74/&trans=success?token=ec-8fj83689wf858702d

i need .htaccess rule trick. including existing .htaccess file make sure other rules not violated.

rewriteengine on rewritebase /  # if not https, redirect rewritecond %{server_port} !^443$ rewriterule ^ https://%{http_host}%{request_uri} [l,r=301]  # if / present, need stop looping (domain.com/) rewriterule ^$ - [l]  # match subdomain rewritecond %{env:redirect_status} ^$ rewritecond %{http_host} !^app rewritecond %{http_host} ^([^\.]+)\.[^\.]+\.[^\.]+$ rewriterule ^(.*)$ /$1?sub=%1 [qsa]  # ignore .php|.html|.asp|.ico files , directories rewriterule ^(exec|images|css|js|xyz|(.*)\.php|(.*)\.html|(.*)\.asp|(.*)\.ico)($|/) - [l]  # stop if index.php rewriterule ^index\.php$ - [l]  # map requests 'path' rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^(.*)$ /index.php?path=$1 [l] 

thanks help!

edited: string broken following query string params

*path* - proxy/091f126b7b6d624623606a1bb67edc430885abaf02ad5975ff2a8276e21fd083091f126b7b6d624623606a1bb67edc430151c3df14a66603f9389b45ec89c9057c76a20ea0b4746ba97d7027e67e9ebc6437dcca31b42521a4794f8e766ab37a76c0e6bd4fc92c60351e7c5fadb37cf0f82210a04bf29a74/  *sub* -  *trans* - success 

please note trans part of path, b/c appended using "&", converted query string param.

htaccess log

init rewrite engine /proxy/091f126b7b6d624623606a1bb67edc430885abaf02ad5975ff2a8276e21fd083091f126b7b6d624623606a1bb67edc430151c3df14a66603f9389b45ec89c9057c76a20ea0b4746ba97d7027e67e9ebc6437dcca31b42521a4794f8e766ab37a76c0e6bd4fc92c60351e7c5fadb37cf0f82210a04bf29a74/&trans=success strip matching prefix: /proxy/091f126b7b6d624623606a1bb67edc430885abaf02ad5975ff2a8276e21fd083091f126b7b6d624623606a1bb67edc430151c3df14a66603f9389b45ec89c9057c76a20ea0b4746ba97d7027e67e9ebc6437dcca31b42521a4794f8e766ab37a76c0e6bd4fc92c60351e7c5fadb37cf0f82210a04bf29a74/&trans=success -> proxy/091f126b7b6d624623606a1bb67edc430885abaf02ad5975ff2a8276e21fd083091f126b7b6d624623606a1bb67edc430151c3df14a66603f9389b45ec89c9057c76a20ea0b4746ba97d7027e67e9ebc6437dcca31b42521a4794f8e766ab37a76c0e6bd4fc92c60351e7c5fadb37cf0f82210a04bf29a74/&trans=success applying pattern ^ uri proxy/091f126b7b6d624623606a1bb67edc430885abaf02ad5975ff2a8276e21fd083091f126b7b6d624623606a1bb67edc430151c3df14a66603f9389b45ec89c9057c76a20ea0b4746ba97d7027e67e9ebc6437dcca31b42521a4794f8e766ab37a76c0e6bd4fc92c60351e7c5fadb37cf0f82210a04bf29a74/&trans=success rewritecond: input='443' pattern='!^443$' => not-matched strip matching prefix: /proxy/091f126b7b6d624623606a1bb67edc430885abaf02ad5975ff2a8276e21fd083091f126b7b6d624623606a1bb67edc430151c3df14a66603f9389b45ec89c9057c76a20ea0b4746ba97d7027e67e9ebc6437dcca31b42521a4794f8e766ab37a76c0e6bd4fc92c60351e7c5fadb37cf0f82210a04bf29a74/&trans=success -> proxy/091f126b7b6d624623606a1bb67edc430885abaf02ad5975ff2a8276e21fd083091f126b7b6d624623606a1bb67edc430151c3df14a66603f9389b45ec89c9057c76a20ea0b4746ba97d7027e67e9ebc6437dcca31b42521a4794f8e766ab37a76c0e6bd4fc92c60351e7c5fadb37cf0f82210a04bf29a74/&trans=success applying pattern ^ uri proxy/091f126b7b6d624623606a1bb67edc430885abaf02ad5975ff2a8276e21fd083091f126b7b6d624623606a1bb67edc430151c3df14a66603f9389b45ec89c9057c76a20ea0b4746ba97d7027e67e9ebc6437dcca31b42521a4794f8e766ab37a76c0e6bd4fc92c60351e7c5fadb37cf0f82210a04bf29a74/&trans=success rewritecond: input='get /proxy/091f126b7b6d624623606a1bb67edc430885abaf02ad5975ff2a8276e21fd083091f126b7b6d624623606a1bb67edc430151c3df14a66603f9389b45ec89c9057c76a20ea0b4746ba97d7027e67e9ebc6437dcca31b42521a4794f8e766ab37a76c0e6bd4fc92c60351e7c5fadb37cf0f82210a04bf29a74/&trans=success http/1.1' pattern='\s/+(.+?)\?(token=[^&\s]+\s*)\s' => not-matched strip matching prefix: /proxy/091f126b7b6d624623606a1bb67edc430885abaf02ad5975ff2a8276e21fd083091f126b7b6d624623606a1bb67edc430151c3df14a66603f9389b45ec89c9057c76a20ea0b4746ba97d7027e67e9ebc6437dcca31b42521a4794f8e766ab37a76c0e6bd4fc92c60351e7c5fadb37cf0f82210a04bf29a74/&trans=success -> proxy/091f126b7b6d624623606a1bb67edc430885abaf02ad5975ff2a8276e21fd083091f126b7b6d624623606a1bb67edc430151c3df14a66603f9389b45ec89c9057c76a20ea0b4746ba97d7027e67e9ebc6437dcca31b42521a4794f8e766ab37a76c0e6bd4fc92c60351e7c5fadb37cf0f82210a04bf29a74/&trans=success applying pattern ^$ uri proxy/091f126b7b6d624623606a1bb67edc430885abaf02ad5975ff2a8276e21fd083091f126b7b6d624623606a1bb67edc430151c3df14a66603f9389b45ec89c9057c76a20ea0b4746ba97d7027e67e9ebc6437dcca31b42521a4794f8e766ab37a76c0e6bd4fc92c60351e7c5fadb37cf0f82210a04bf29a74/&trans=success strip matching prefix: /proxy/091f126b7b6d624623606a1bb67edc430885abaf02ad5975ff2a8276e21fd083091f126b7b6d624623606a1bb67edc430151c3df14a66603f9389b45ec89c9057c76a20ea0b4746ba97d7027e67e9ebc6437dcca31b42521a4794f8e766ab37a76c0e6bd4fc92c60351e7c5fadb37cf0f82210a04bf29a74/&trans=success -> proxy/091f126b7b6d624623606a1bb67edc430885abaf02ad5975ff2a8276e21fd083091f126b7b6d624623606a1bb67edc430151c3df14a66603f9389b45ec89c9057c76a20ea0b4746ba97d7027e67e9ebc6437dcca31b42521a4794f8e766ab37a76c0e6bd4fc92c60351e7c5fadb37cf0f82210a04bf29a74/&trans=success applying pattern ^(.*)$ uri proxy/091f126b7b6d624623606a1bb67edc430885abaf02ad5975ff2a8276e21fd083091f126b7b6d624623606a1bb67edc430151c3df14a66603f9389b45ec89c9057c76a20ea0b4746ba97d7027e67e9ebc6437dcca31b42521a4794f8e766ab37a76c0e6bd4fc92c60351e7c5fadb37cf0f82210a04bf29a74/&trans=success rewritecond: input='' pattern='^$' => matched rewritecond: input='demo.samplesite.com' pattern='!^app' => matched rewritecond: input='demo.samplesite.com' pattern='^([^\.]+)\.[^\.]+\.[^\.]+$' => matched rewrite url >> /proxy/091f126b7b6d624623606a1bb67edc430885abaf02ad5975ff2a8276e21fd083091f126b7b6d624623606a1bb67edc430151c3df14a66603f9389b45ec89c9057c76a20ea0b4746ba97d7027e67e9ebc6437dcca31b42521a4794f8e766ab37a76c0e6bd4fc92c60351e7c5fadb37cf0f82210a04bf29a74/&trans=success?sub=demo&token=ec-76d265115n209873k [rewrite] 

have way:

rewriteengine on rewritebase /  # if not https, redirect rewritecond %{server_port} !^443$ rewriterule ^ https://%{http_host}%{request_uri} [l,r=302]  # convert ?token=... &token=... rewritecond %{the_request} \s/+(.+?)\?(token=[^&\s]+\s*)\s [nc] rewriterule ^ /%1&%2? [l,ne,r=302]  # if / present, need stop looping (domain.com/) rewriterule ^(index\.php)?$ - [l,nc]  # match subdomain rewritecond %{env:redirect_status} ^$ rewritecond %{http_host} !^app rewritecond %{http_host} ^([^.]+)\.[^.]+\.[^.]+$ rewriterule ^(.*)$ $1?sub=%1 [l,qsa]  # ignore .php|.html|.asp|.ico files , directories rewriterule ^(exec|images|css|js|xyz|(.*)\.php|(.*)\.html|(.*)\.asp|(.*)\.ico)($|/) - [l]  # map requests 'path' rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^(.+)$ index.php?path=$1 [l,qsa] 

update:

while testing url:

http://abc.dev.localhost/proxy/foobar/&trans=success?token=ec-8fj83689wf858702d 

it redirects to:

http://abc.dev.localhost/proxy/foobar/&trans=success&token=ec-8fj83689wf858702d 

and displays print_r($_get) output:

array (     [path] => proxy/foobar/     [trans] => success     [token] => ec-8fj83689wf858702d     [sub] => abc ) 

Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - How to Hide Date Menu from Datepicker in yii2 -