getting the current page full URL
Started by mikef, Nov 16 2007 04:57 PM
7 replies to this topic
#1
Posted 16 November 2007 - 04:57 PM
I'd like to be able to get hold of the actual url a page was obtained with (including ? parameters and any # anchor), in order to use in a snippet. Is there any way of obtaining this?
#2
Posted 16 November 2007 - 05:38 PM
http://www.dreamincode.net/code/snippet104.htm
return $_SERVER['FULL_URL']; will give the query string used in the browser It may have to be decoded.
Yeah I know... I'm bored.
<?
$_SERVER['FULL_URL'] = 'http';
if($_SERVER['HTTPS']=='on'){$_SERVER['FULL_URL'] .= 's';}
$_SERVER['FULL_URL'] .= '://';
if($_SERVER['SERVER_PORT']!='80') $_SERVER['FULL_URL'] .= $_SERVER['HTTP_HOST'].':'.$_SERVER['SERVER_PORT'].$_SERVER['SCRIPT_NAME'];
else
$_SERVER['FULL_URL'] .= $_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'];
if($_SERVER['QUERY_STRING']>' '){$_SERVER['FULL_URL'] .= '?'.$_SERVER['QUERY_STRING'];}
?>
return $_SERVER['FULL_URL']; will give the query string used in the browser It may have to be decoded.
Yeah I know... I'm bored.
Edited by Cris D., 16 November 2007 - 05:48 PM.
#3
Posted 16 November 2007 - 05:41 PM
$url = $etomite->makeUrl($etomite->documentIdentifier); should do the trick... Or you can use [(www_base_path)][*alias*][(friendly_url_suffix)] or [(www_base_path)]/index.php?id=[*id*] if you aren't using FURL's or Aliases...
#4
Posted 16 November 2007 - 08:39 PM
Thanks Cris, I'll look into those later.
Ralph, your suggestions will give me what etomite thinks the url for the page ought to be, not what was actually used, complete with any query parameters or anchor specifications. The format I use for my site for the expected base url is [(www_base_path)][~[*alias*]~] which I think also caters for friendly URL prefixes (not that I use one).
Thinking about it further, what I really really want is the url before going through the .htaccess rules, but I don't think thats likely to be available.
Ralph, your suggestions will give me what etomite thinks the url for the page ought to be, not what was actually used, complete with any query parameters or anchor specifications. The format I use for my site for the expected base url is [(www_base_path)][~[*alias*]~] which I think also caters for friendly URL prefixes (not that I use one).
Thinking about it further, what I really really want is the url before going through the .htaccess rules, but I don't think thats likely to be available.
#5
Posted 17 November 2007 - 03:46 PM
mikef, on Nov 16 2007, 03:39 PM, said:
Thinking about it further, what I really really want is the url before going through the .htaccess rules, but I don't think thats likely to be available.
Combining any of these with [(server_protocol)], which returns either http[/] or https gives pretty complete flexibility... I gathered thses settings by snooping around in Etomite manager > View system info > Server Information > View and [b]Etomite manager > Etomite configuration > Site settings and checking the available Etoimite system tags...
Not sure if this helps, but someone may find the information helpful...
#6
Posted 17 November 2007 - 05:56 PM
Thanks Ralph. I think the three $_SERVER parts may give me what I need. time to play around ... once I've figured out how to center an image in a div (there are times I hate CSS)
#7
Posted 17 November 2007 - 09:38 PM
mikef, on Nov 16 2007, 08:39 PM, said:
The format I use for my site for the expected base url is [(www_base_path)][~[*alias*]~] which I think also caters for friendly URL prefixes (not that I use one).
Shouldn't that be [(www_base_path)][~[*id*]~] ? That'd generate the correct url depending on the configuration....
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











