Jump to content

Redirecting and changing the URL


gameshints

Recommended Posts

I have a login page which remembers what you were trying to access, then uses header('Location: url here') to redirect the user back to what they were trying to access after a successful password.

 

However, the URL remains my.domain.here/login.php, instead of where they were redirected to... which breaks my relative links if they are redirected to a page within a subdirectory.

 

Any ideas?

 

Thanks,

Erik

Link to comment
https://forums.phpfreaks.com/topic/65639-redirecting-and-changing-the-url/
Share on other sites

Yeah, that's my issue.  The browser (both Firefox 2 and IE 7) doesn't update the address bar, and then uses  that old address to calculate the relative links... so everything breaks.

 

Since both browsers did it, I assumed there is something I can do in PHP.

Whoops... Just re-read your first post.

You'll need php, not HTML for the redir page.

 

When they login, send a location header like this: redir.php?http://redirect.to.here.com

Then redir.php will do the meta-tag refresh to take them to the URL in the query string.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.