doubledee Posted August 25, 2011 Share Posted August 25, 2011 I am using PHP's redirect and the manual says... HTTP/1.1 requires an absolute URI as argument to » Location: including the scheme, hostname and absolute path, but some clients accept relative URIs. 1.) How important is this really? 2.) When it says "Absolute Path" for they mean the "File Path" or "Web Path"? 3.) Can I just use one of these constants in my config.inc.php file which goes like... <?php define('ENVIRONMENT', 'development'); //define('ENVIRONMENT', 'production'); // File Root define('ROOT', ENVIRONMENT === 'development' ? '/Users/user1/Documents/DEV/++htdocs/01_MyProject/' : '/var/www/vhosts/mywebsite.com/httpdocs/'); // Web Server Root define('WEB_ROOT', ENVIRONMENT === 'development' ? 'http://local.dev/' : 'http://www.mywebsite.com/'); ?> Would that work? Debbie Quote Link to comment https://forums.phpfreaks.com/topic/245651-question-about-absolute-uri/ Share on other sites More sharing options...
trq Posted August 25, 2011 Share Posted August 25, 2011 Because a redirect is a Location header sent to the client, it needs to be something the client understand. A URL. So yeah, a complete URL (including the domain name) is required. Some browsers will handle a relative URL but it is not recommended. Quote Link to comment https://forums.phpfreaks.com/topic/245651-question-about-absolute-uri/#findComment-1261669 Share on other sites More sharing options...
doubledee Posted August 25, 2011 Author Share Posted August 25, 2011 Because a redirect is a Location header sent to the client, it needs to be something the client understand. A URL. So yeah, a complete URL (including the domain name) is required. Some browsers will handle a relative URL but it is not recommended. So I changed my code to this... // Redirect User. if (isset($_SESSION['returnToPage'])){ header("Location: " . WEB_ROOT . $_SESSION['returnToPage']); }else{ // Take user to Home Page. header("Location: " . WEB_ROOT . "index.php"); } Is that okay? Debbie Quote Link to comment https://forums.phpfreaks.com/topic/245651-question-about-absolute-uri/#findComment-1261670 Share on other sites More sharing options...
cssfreakie Posted August 25, 2011 Share Posted August 25, 2011 Is that okay? Look okay to me. Did you try it? Quote Link to comment https://forums.phpfreaks.com/topic/245651-question-about-absolute-uri/#findComment-1261671 Share on other sites More sharing options...
doubledee Posted August 25, 2011 Author Share Posted August 25, 2011 Is that okay? Look okay to me. Did you try it? Yes, and it works, but then so did my Relative path. Figured I better ask here before I blow up my production website!! (BTW, ask me about my "new & improved" Log-In page with most of my PHP at the beginning before the HTML, not Header issues, and a re-direct that actually works?!) Debbie Quote Link to comment https://forums.phpfreaks.com/topic/245651-question-about-absolute-uri/#findComment-1261673 Share on other sites More sharing options...
cssfreakie Posted August 25, 2011 Share Posted August 25, 2011 (BTW, ask me about my "new & improved" Log-In page with most of my PHP at the beginning before the HTML, not Header issues, and a re-direct that actually works?!) I assume it works? if so well done! Quote Link to comment https://forums.phpfreaks.com/topic/245651-question-about-absolute-uri/#findComment-1261675 Share on other sites More sharing options...
doubledee Posted August 25, 2011 Author Share Posted August 25, 2011 (BTW, ask me about my "new & improved" Log-In page with most of my PHP at the beginning before the HTML, not Header issues, and a re-direct that actually works?!) I assume it works? if so well done! So far... so good... Time will tell?! Debbie Quote Link to comment https://forums.phpfreaks.com/topic/245651-question-about-absolute-uri/#findComment-1261677 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.