Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IIS, header() problem

Status
Not open for further replies.

planix

Technical User
Dec 3, 2002
22
Hi,

I know that there is a problem with IIS and redirecting using the header() function. But, does anyone have a workaround for this code?

The purpose of the code is to build an expression ($url) to redirect to and then redirect to that built location.

Code:
 function redirect($url, $includeJournal = true) {
                if (!preg_match('!^https?://!i', $url)) {
                        $url = Request::getBaseUrl() . '/' . $url;
                }
                header("Location: $url");

                exit();
        }

The problem is, obviously, that nothing happens because it is IIS trying to use the header() function and doing some obscure thing with the 302 (whatever that is!) page.

Anyway, can somebody give me any clues as to how to redirect the page without using location() or by adding some smart bit of meta tag processing?

Many thanx

Alistair
 
This is an absolute link: This kind of link absolutely defines where the page can be found.

This is a relative link: /fee/fi/foe/fum.html Such links only mean something relative to another page or site.


Also, have you tried prepending "nph-" to your PHP script's filename? The "No Parse Headers" prepend can make IIS leave your headers alone.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Thanks. That actually makes some sense to me. I think I have a hard time understanding the file structure or servers so the idea of absolute and relative gets mixed up with whether I am thinking server file structure or web file structure.

I will try the 'nph' idea. Does that generally lead to IIS leaving Cookie transactions alone as well. I know there is the problem of it ignoring Cookies if you send a header call as well. I just wondered, not for this problem, whether that would fix this issue as well.

Cheers

Alistair
 
Microsoft has a unique interpretation of the HTTP spec, particularly as it applies to headers and response codes. If you dig around in the Microsoft knowledge base, you'll find some article where they deliberately wrote IIS so that it won't both send cookies and use the "Location" header in a single transaction.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
So, is there a straightforward, generic fix to this?

I have read some posts about using Meta tags to refresh in some circumstances. Is it possible to say that, when sending cookies and using the Location header in IIS, you should first call;

header(parameters)

then call

<meta http-equiv=\"refresh\" content=\"0;URL=$sUrl\">

or some such?

Basically, I keep running across this problem in slightly different contexts. I want to know what my general response could be so I can adpat some coding solution to the range of difficulties.

Cheers

Alistair
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top