Link to home
Start Free TrialLog in
Avatar of Neil Thompson
Neil ThompsonFlag for United Kingdom of Great Britain and Northern Ireland

asked on

IIS is re-writing my header('location and altering the URL

I've got a weird one here that I really need help with

I have a bit of PHP code that is used for payments, as of today the server it is on is being proxied though IIS, all has been working fine.

Now, when the page is called rather than going to the URL specified in the header( Location it re-writes it to the current site URL, then adds the rest.

EG.

I'm on my site http://www.aaa.co.uk, and my header refresh page is called, this should send me to http://www.bbb.co.uk/this-is-a-test/page

header('Location: http://www.bbb.co.uk/this-is-a-test/page');

What actually happens is the page redirects and rewrites the www.bbb.co.uk to www.aaa.co.uk trying to take me to:

http://www.aaa.co.uk/this-is-a-test/page

Using meta refresh or opening a new window using JS works perfectly and keeps the required bbb URL

Any ideas please, its killing me :)
SOLUTION
Avatar of David Johnson, CD
David Johnson, CD
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I have never seen PHP header get changed on IIS 5, 6, or 7.  I think there's more to your code than you are telling us.
Avatar of Neil Thompson

ASKER

Thanks, annoyingly the IIS is controlled by a 3rd party at present as they are proxying /capitapay through to this server from the website.

They are still saying its not IIS but I'm sure it is as this demo should prove:

<?php

// http://www.shepway.gov.uk/capitapay/fund/ctx/test.php

$location = "https://sbs.e-paycapita.com:443/scp/scpcli?ssk=gybitihsltss6ng27sp56tivneg1ewa";
header('Location: ' . $location);

?>

Open in new window


If you click on this test link: http://www.shepway.gov.uk/capitapay/fund/ctx/test.php you will see that the URL is re-written and the https://sbs.e-paycapita.com:443 is removed leaving the URL http://www.shepway.gov.uk/scp/scpcli?ssk=gybitihsltss6ng27sp56tivneg1ewa 

There are no other pages involved so there are no other influences changing the URL
No, I'm just getting a 404 Not Found.
Thanks Dave and David

That's right, when on the Shepway site (/capitapay being proxied from the IIS server serving the site to another in the DMZ) it errors by re-writing the https://sbs.e-pay... to http://www.shepway

People sorting out the proxying and IIS say its not them but surely it is if it works when you move the code away, and it works?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
moving any of the servers is not an option :(
Thanks Guys, still not working but Its not my code, rather something on the 3rd party site that I need them to take ownership of :(
Just thought I would revisit this in case it helps anyone with a similar situation.

In the end the fix (although I don't know why) was simple. Rather than calling the URL to be opened using the standard HTTP:// prefix I simply used the now more common // prefix (excluding the http:) and it worked instantly.

Since then I've had the issue (and fixed it this way) on a few jobs for different clients.

Hope it helps :) Neil