Linked Questions
24 questions linked to/from PHP $_SERVER['HTTP_HOST'] vs. $_SERVER['SERVER_NAME'], am I understanding the manual pages correctly?
592 votes
25 answers
463k views
Detect when a browser receives a file download
I have a page that allows the user to download a dynamically-generated file. It takes a long time to generate, so I'd like to show a "waiting" indicator. The problem is, I can't figure out ...
585 votes
11 answers
484k views
What is the difference between HTTP_HOST and SERVER_NAME in PHP?
What is the difference between $_SERVER['HTTP_HOST'] and $_SERVER['SERVER_NAME'] in PHP? When would you consider using one over the other and why?
266 votes
11 answers
191k views
What's quicker and better to determine if an array key exists in PHP?
Consider these 2 examples... $key = 'jim'; // example 1 if (isset($array[$key])) { // ... } // example 2 if (array_key_exists($key, $array)) { // ... } I'm interested in knowing if ...
223 votes
9 answers
545k views
Get current domain
I have my site on the server http://www.example.uk.com. On this server I have two domains: one.example two.example I would like to get the current domain using PHP, but if I use $_SERVER['HTTP_HOST']...
137 votes
15 answers
335k views
How can I get the current page's full URL on a Windows/IIS server?
I moved a WordPress installation to a new folder on a Windows/IIS server. I'm setting up 301 redirects in PHP, but it doesn't seem to be working. My post URLs have the following format: http:://www....
41 votes
17 answers
293k views
How to set proper codeigniter base url?
when I had my site on development environment - it was url: testurl.com Now on production server my codeigniter app's address has to be someurl.com/mysite/ I moved it there, and everytime I'm trying ...
109 votes
2 answers
21k views
Which $_SERVER variables are safe?
Any variable that a user can control, an attacker can also control and is therefore a source of an attack. This is called a "tainted" variable, and is unsafe. When using $_SERVER, many of the ...
86 votes
2 answers
341k views
PHP get domain name [duplicate]
I want to get the domain name for where the script is running. How can that be done with PHP? I see that $_SERVER['HTTP_HOST'] as well as $_SERVER['SERVER_NAME'] contain this information. Will that ...
23 votes
3 answers
81k views
PHP: $_SERVER variables: $_SERVER['HTTP_HOST'] vs $_SERVER['SERVER_NAME'] [duplicate]
Possible Duplicate: HTTP_HOST vs. SERVER_NAME What is the difference between $_SERVER['HTTP_HOST'] and $_SERVER['SERVER_NAME'] ??
3 votes
1 answer
21k views
Get client's domain name using php [duplicate]
I have problem with getting domain name using HTTP_REFERER. The condition is like this: http://www.example.com send a curl post to my server. The things is, example.com does not send their url in ...
1 vote
1 answer
10k views
Joomla $app->redirect() in template index.php causing a redirect loop
I am attempting to redirect in a template index.php i am building and getting a redirect loop. Am I missing something? What I am attempting to do is redirect the default page depending on the entry ...
1 vote
1 answer
6k views
Validate domain name PHP [duplicate]
I need to validate domain names using PHP. Only this format should be allowed: google.com, subdomain.stack-overflow.org etc It should only allow - (in case of special characters) No other format ...
-3 votes
1 answer
4k views
How to get domain name with PHP
I know (and see) that this question has been asked for about a thousand times, but, after search and search, and somewhat confusing answers, i'm still looking for a right answer. All I need is to ...
1 vote
1 answer
2k views
How to make your custom php CMS work only on a certain domain for a certain time?
I want to prevent coping my custom made CMS from domain to domain and I want that it is operable only on a doain that it is bought for and onluy for the period 1, 2 years from the purchase. The code ...
0 votes
1 answer
2k views
session_set_cookie_params() points to the wrong domain
I'm having some pretty weird error when I want to set my session cookie. If I use the following rule: session_set_cookie_params(0, '/', $_SERVER['HTTP_HOST'], false, true); //$_SERVER['HTTP_HOST'] ...