Jump to content

Question about Absolute URI


doubledee

Recommended Posts

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

 

 

Link to comment
https://forums.phpfreaks.com/topic/245651-question-about-absolute-uri/
Share on other sites

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

 

 

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?!)  8)

 

 

Debbie

 

 

(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?!)  8)

 

I assume it works?  ;D

if so well done!

(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?!)  8)

 

I assume it works?  ;D

if so well done!

 

So far... so good...

 

Time will tell?!

 

 

Debbie

 

 

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.