We are transitioning over to a new forum platform. Please post new issues there. Existing threads will be dealt with here unless you choose to move them over. Visit the new forum
Outputting the current url with routed pages
I'm trying to create a semi-automated
<link rel="canonical"> tag in the head.
This usually works fine like this:
PerchSystem::set_var("current_url", perch_page_url(array( "include-domain" => true, "hide-extensions" => true), true));
then in my page attributes HTML file:
<link rel="canonical" href="<perch:pages id="current_url" type="hidden"/>" />
The problem I have is that this does not work for 'routed' pages in Runway. e.g. for
perch_page_url may only return
I was then tempted to just echo the real URL like this:
PerchSystem::set_var("current_url", (isset($_SERVER['HTTPS']) ? "https://" : "http://").$_SERVER["HTTP_HOST"] . $_SERVER['REQUEST_URI']);
However, I've read security warnings about doing things like this: https://expressionengine.com/blog/http-host-and-server-name-security-issues
Is that a valid concern? Is there a safe way of echoing out the full URL?
Want to reply to this thread?Login with Perch