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

Link to comment
Share on other sites

BASE_URL isn't a PHP constant, I don't know how it has been defined in your code but I think that it refers to the "URL" to your script which is : "localhost/ICU"

 

So I guess that it may work if you do :

 

$url = "http://".BASE_URL."/index.php";

Link to comment
Share on other sites

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'

 

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.