ted_chou12 Posted January 1, 2007 Share Posted January 1, 2007 $page = $_SERVER['PHP_SELF'];header("Location: $page");the code above does seem to work, i dont know why, what I want to do is to redirect to the current url after the login. Can anyone help me please?ThanksTed Link to comment https://forums.phpfreaks.com/topic/32467-redirect-to-the-current-url/ Share on other sites More sharing options...
glenelkins Posted January 1, 2007 Share Posted January 1, 2007 try this$protocol = explode("/",$_SERVER['SERVER_PROTOCOL']);$protocol = strtolower($protocol[0]);$page = $protocol . "://" . $_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; Link to comment https://forums.phpfreaks.com/topic/32467-redirect-to-the-current-url/#findComment-150827 Share on other sites More sharing options...
ted_chou12 Posted January 1, 2007 Author Share Posted January 1, 2007 nope, i changed my mind, for php self, you would get something like this:/users/index.phpbut what I want to do, is to strip the first slash, the slash before user, how would I do that? Link to comment https://forums.phpfreaks.com/topic/32467-redirect-to-the-current-url/#findComment-150828 Share on other sites More sharing options...
ted_chou12 Posted January 1, 2007 Author Share Posted January 1, 2007 thanks by the way... Link to comment https://forums.phpfreaks.com/topic/32467-redirect-to-the-current-url/#findComment-150830 Share on other sites More sharing options...
JasonLewis Posted January 1, 2007 Share Posted January 1, 2007 try this:[code=php:0]$page = $_SERVER['REQUEST_URI'];[/code]that gets the current url in the address bar.or if you want to use php_self then do this to it:[code=php:0]$page = substr($_SERVER['PHP_SELF'], 1);[/code] Link to comment https://forums.phpfreaks.com/topic/32467-redirect-to-the-current-url/#findComment-150998 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.