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
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.

Link to comment
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

 

 

Link to comment
Share on other sites

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

 

 

Link to comment
Share on other sites

(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

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.