Jump to content

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

define ('BASE_URL', 'localhost/ICU');

you are right its down to how I defined the base url

I thought the code would work as follows though:

Base url = Localhost/icu + /index.php

localhost/icu/index.php

not

localhost/icu/localhost/icu/index.php

 

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'

 

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.