Jump to content

Trouble with BASE_URL and re-directing


valgris

Recommended Posts

Hello I am having another minor issue where I am unable to spot where I am going wrong.

 

The code for my logout button should redirect the user to index.php however I seem to be having an issue with the url. This is on my test server and I am using

$url = BASE_URL . 'index.php'; // Define the URL.

however the button seems to be taking me to:

 

An I am not quite sure why, the base_url should be localhost/ICU or localhost but the url given out is localhost/ICU/Localhost/ICUindex.php.

why is it repeating itself?

So where am I going wrong, is it in my understanding of the BASE_URL or something else?

 

As always thank you in advance for any help.

Link to comment
https://forums.phpfreaks.com/topic/254816-trouble-with-base_url-and-re-directing/
Share on other sites

Okay that makes so much more sense, I think I need to call it a night.

Though I could even use "."

However I would still like to know where I went wrong with the BASE_URL, I am going wrong somewhere and for future reference it would be good to know.

Thank you MrGary

Unless a URL begins with http:// or https://, then it is treated as a relative URL.  If it begins with a '/' it refers to the root but uses the current domain name/scheme.  Otherwise, it is based on your current directory.

 

So your base of 'localhost/ICU' combined with '/index.php' = 'localhost/ICU/index.php'

 

Since it doesn't start with a '/' or a scheme, it is relative to the current directory, which is already http://localhost/ICU.

 

'http://localhost/ICU' + 'localhost/ICU/index.php' = 'http://localhost/ICU/localhost/ICU/index.php'

 

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.