Hi there,
I’m trying to access the first part of the URL path via PHP, for example:
example.com/en/article-title/ → I want to get "en" as a language or path segment.
I’ve tried using $_SERVER['REQUEST_URI'] , REDIRECT_URL , SCRIPT_NAME , and others – inside hooks like template_redirect and wp_head . But by the time these run, the URL appears to have been rewritten (possibly by Cornerstone or another system), and I only get / or the internal path.
I need to capture this information early during page load (ideally before <head> is rendered), and I can’t rely on JavaScript or cookies – this must work for both users and crawlers (server-side only).
Is there a recommended way in Pro/Cornerstone to access the original request path or first URL segment before Cornerstone has fully processed the page?
Thanks a lot!