tags:

views:

1388

answers:

2

Hey there! Here is my issue, it could just be a browser issue but any help/ideas would be awesome!

Pretty much I have the following redirect:

header("Location: page.php#images");

In most modern browsers it will redirect to page.php#images without any problems but in IE it seems to strip the #images. Has anyone come across this? So far my only option (which I think is a terrible option) is to redirect through JavaScript.

thanks!

UPDATE
I sent up a simple sandbox and it seems to work fine with or without an absolute URL. I guess there is something else going on in my actual app that is conflicting with it. I'll update when I figure it out, thanks for all the responses!

UPDATE 2
I found out what the problem is but I am still unsure on the fix. It turns out that it was a file input that was breaking it. You can see it in action here http://www.stiprojects.com/anchor/ it works fine in firefox but breaks in IE. the source code in the redirect is:

header("Location: http://www.stiprojects.com/anchor/index.php?one=1&two=2#/images");

Do you see anything that I'm not seeing? I'm so confused!

A: 

Yes that is true. It can be prevented if you use an absolute path:

header("Location: http://www.example.com/page.php#images");
動靜能量
+1  A: 

The Location header requires an absolute path per the HTTP specification. Try using an absolute path. The errata says that document fragments (#id) are allowed in the Location header, but the behaviour when a user is linked to a page with a fragment (e.g. http://example.org/a_redirector#this where a_redirector redirects to http://example.com/destination#that) is undefined.

Paul Fisher