here situation in smallest explanation can give.
from php, redirect following function
function redirect($loc) { session_write_close(); header("location: $loc"); exit(); }
for example, redirect('http://www.google.com/');
the problem when attempt redirect('https://local.application.com')
browser gets header says location: https://local-apps.application.com
. https://local-apps.application.com
uri original request comes through.
i've used xdebug step through php code right header('location: $loc');
call , can verify 100% $loc == 'https://local.application.com'
because xdebug tells me so. however, reason, browser gets location: https://local-apps.application.com
. causes infinite loop https://local-apps.application.com
once again redirects https://local.application.com
.
what maybe going on?!
the extremely weird part putting same exact code in our qa environment yields expected behavior , no inifinite loop caused. in qa urls qa-apps.application.com , qa.application.com.
i don't know if local apache doing this. doubt it's php's fault because xdebug shows me $loc variable set right uri , i'm doing exit
right after.
i've tried using charles web proxy act man in middle @ traffic shows location: https://local-apps.application.com
instead of expected location: https://local.application.com
.
is there apache setting alter outgoing headers? should do?
edit 1
i altered apache access log print out location header in response , correct value. apache isn't doing weird here.
edit 2
i removed entries /etc/hosts file. installed dnsmasq , set primary dns server computer. tested doing dig @127.0.0.1 local.application.com
, dig @127.0.0.1 www.google.com
make sure had set correctly.
i added address=/local.application.com/127.0.0.1
, address=/local-apps.application.com/127.0.0.1
dnsmasq config , restarted dnsmasq. restarted computer after setting daemon starts on reboot.
i same weird behavior on local machine. webbrowser goes infinite loop.
more info if curious
i'm putting oauth2 implementation in workplace.
the authorize point exists on local machine @ local-apps.application.com/authorize (local-apps) because that's mobile apps access it. in production apps.application.com/authorize. (sorry, can't control subdomains being used).
depending on client_id in initial oauth2 auhorize request first redirect client appropriate domain. local-apps.application.com/authorize
i'll go local.client-1.com/authorize
, there redirect local.client-1.com/login
if oauth2 credentials validated successfully.. why redirect? 1. limitation in way our templating system works , fact depends on domain load proper html. 2. sessions php don't transfer across domains have start php session on right domain. can't change it. have deal it. please don't make suggestions related url scheme thingy. want know why php redirects 1 url , browser different url in header.
it seems, have same ip addresses in /etc/hosts file or can check apache virtual host file make sure correct path. note: apache configuration files location , directory structure depends on linux distro.
Comments
Post a Comment