jarvis Posted January 29, 2013 Share Posted January 29, 2013 I really hope someone can help! I currently use the following to get a URL: $pageURL=''; $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; $filename = basename($pageURL); I could then echo $filename and use it elsewhere in my code. However, I've an issue with the a URL that contains Googles UTM code, for example: http://www.domain.co.uk/2013/02/14/?utm_source=COMPANY&utm_medium=email&utm_term=NewsletterLink&utm_campaign=Newsletter&utm_content= How can I use the above but strip out the ?utm... I've tried a preg_replace but couldn't seem to get it working. Any help is much appreciated! TIA Link to comment https://forums.phpfreaks.com/topic/273791-remove-utm-code-from-url/ Share on other sites More sharing options...
Psycho Posted January 29, 2013 Share Posted January 29, 2013 parse_url Link to comment https://forums.phpfreaks.com/topic/273791-remove-utm-code-from-url/#findComment-1408972 Share on other sites More sharing options...
requinix Posted January 29, 2013 Share Posted January 29, 2013 Look in $_SERVER for something like the REQUEST_URI but that doesn't contain the query string. For the query string, $get = $_GET; if (isset($get["utm_source"])) unset($get["utm_source"]); // etc if ($get) $url .= "?" . http_build_query($get); Link to comment https://forums.phpfreaks.com/topic/273791-remove-utm-code-from-url/#findComment-1409006 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.