This is a discussion on "[SOLVED] Getting the current domain" within the PHP Forum section. This forum, and the thread "[SOLVED] Getting the current domain are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
[SOLVED] Getting the current domain
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
#1
|
|||
|
|||
|
[SOLVED] Getting the current domain
I want to assign a variable to the current domain of the web page. When I'm developing the site, the domain is "http://localhost/", but when I upload it the domain is "http://www.badmintonbible.com/".
So I'm using this variable to make links work both locally and on the site itself. I've tried using $_SERVER['DOCUMENT_ROOT'], but this goes too deep: it returns all the server's file structure. There must be a pre-assigned variable for this, but I haven't found it. Any ideas? |
|
|
|
#2
|
|||
|
|||
|
Re: Getting the current domain
I had the same problem and here's my solution. This function returns the current domain plus the folder structure to where the file is located plus a trailing slash:
Last Blog Entry: 10 Reasons Why My Laptop Is Better Than Your Girlfriend (Dec 15th, 2007)
Last edited by c010depunkk; Nov 22nd, 2007 at 17:05. |
|
#3
|
|||
|
|||
|
Re: Getting the current domain
Hmmmm ... I can't test any of this as I don't have access but... have you tried
'HTTP_HOST' |
|
#4
|
|||
|
|||
|
Re: Getting the current domain
what karinne said:
this has always worked for me
|
|
#5
|
|||
|
|||
|
Re: Getting the current domain
Quote:
Thanks everyone! |
![]() |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| highlight current page | unitedcraig | Web Page Design | 53 | Feb 13th, 2008 22:20 |
| [SOLVED] close current window in php script | Posie | PHP Forum | 7 | Dec 14th, 2007 05:38 |
| [SOLVED] Domain Fowarding? Good Idea? | TheSealPortalTeam | Web Page Design | 9 | Dec 2nd, 2007 13:31 |
| Getting current URL in java | QuikFrozen | Other Programming Languages | 3 | Mar 27th, 2007 23:38 |