Picture of Paul Silver

Paul Silver

Making websites for companies and helping advertise them

Save the current URL in to a variable using ColdFusion

Someone found one of my other pages looking for this, and here's how you do it:

#CGI.SCRIPT_NAME# will give you the path of the page and it's filename, e.g. "/coldfusion_articles/coldfusion_current_url.cfm" is the path of this web page.

#CGI.SERVER_NAME# gives you the name of the web server, e.g. "www.tenpastmidnight.com"

If you want to put it all together in to a variable, do it like this:


Which in the case of this page is: "http://www.paulsilver.co.uk/code/coldfusion_current_url.php" (if this was a CF page rather than PHP.)

More code articles

Paul Silver. November 2003

© 2024 Paul Silver & Silver Web Services Ltd