gameshints Posted August 19, 2007 Share Posted August 19, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/65639-redirecting-and-changing-the-url/ Share on other sites More sharing options...
marcus Posted August 19, 2007 Share Posted August 19, 2007 Show code? Quote Link to comment https://forums.phpfreaks.com/topic/65639-redirecting-and-changing-the-url/#findComment-327827 Share on other sites More sharing options...
pkSML Posted August 19, 2007 Share Posted August 19, 2007 One thing to check... After a successful login, go to File -> Properties and check the URL for the page. Sometimes the browser, for whatever reason, does not update the address bar after a page change though you're actually at a new page. Quote Link to comment https://forums.phpfreaks.com/topic/65639-redirecting-and-changing-the-url/#findComment-327843 Share on other sites More sharing options...
gameshints Posted August 19, 2007 Author Share Posted August 19, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/65639-redirecting-and-changing-the-url/#findComment-327844 Share on other sites More sharing options...
pkSML Posted August 19, 2007 Share Posted August 19, 2007 How are you redirecting? PHP header? If PHP, what is the HTTP status code? Quote Link to comment https://forums.phpfreaks.com/topic/65639-redirecting-and-changing-the-url/#findComment-327849 Share on other sites More sharing options...
gameshints Posted August 19, 2007 Author Share Posted August 19, 2007 I'm using header("Location: http://www.example.com/some/sub/directory") which is redirecting using a 302 moved temporary redirect. I also tried a 301 permanent redirect and it didn't work either. Quote Link to comment https://forums.phpfreaks.com/topic/65639-redirecting-and-changing-the-url/#findComment-327853 Share on other sites More sharing options...
pkSML Posted August 19, 2007 Share Posted August 19, 2007 Maybe you could make an intermediary webpage. Redirect them to redir.htm with the PHP location header. Then in redir.htm, use a meta-tag refresh to point them to the logged-in location. Quote Link to comment https://forums.phpfreaks.com/topic/65639-redirecting-and-changing-the-url/#findComment-327856 Share on other sites More sharing options...
pkSML Posted August 19, 2007 Share Posted August 19, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/65639-redirecting-and-changing-the-url/#findComment-327858 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.