Link to home
Start Free TrialLog in
Avatar of rgb192
rgb192Flag for United States of America

asked on

get url (including subdomain)

want the entire page url, including subdomain

I would like (if possible)
subdomain to be $variable1
domain to be $variable2
uri to be $variable3
Avatar of gplana
gplana
Flag of Spain image

you have a string with the whole URL on the variable:

$_SERVER['PHP_SELF']

then you can split string by using php functions to get different parts of string. Functions like strpos to get the position of a character inside an string, or functions like substr to get a part of the string.

Here you have the list of all string functions:
http://www.php.net/manual/en/ref.strings.php

Hope it helps.
ASKER CERTIFIED SOLUTION
Avatar of Brad Brett
Brad Brett
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I generally agree with Medo3777, however the URL might be something like www.atf77.whitehouse.gov/csm/index.php?q=foo.bar so you might want to learn about the PHP functions that parse strings and parse urls.  Google those terms and you will find a wealth of generalized solutions for parsing this sort of information.
Avatar of rgb192

ASKER

i will have to open a question about a complex url that Ray suggested