Hello, I am trying to have a link to a page, retrieve the current URL and then change the .com and use the current /folder... Like: <a href ="<?php GetCurrentURL = http://www.mydomain.com/go/ change it to = http://www.mydomain2.com/go/ ?> ">HERES MY LINK</> Code (markup): The folder does not change, but the .com does. Thanks!
By "current URL" do you mean the webpage that the link is actively on? If so, maybe this is what you want (small chance I might be wrong ) : $forwardto = "somedomain.com"; $currentURL = parseurl($_SERVER['URI_SCRIPT']); $outputURL = $forwardto.$currentURL['path']; PHP: This should turn "example.com/some/random/directory" to "somedomain.com/some/random/directory".
Or are you scraping content from someone else's site and changing the links to point to your own site, and then give dynamic search results?
$theurl= parseurl($_SERVER['URI_SCRIPT']); $theurl= str_replace("mydomain", "mydomain2", $theurl); echo"$theurl"; PHP:
This code is a bit redundant in that it's going to search through every single element in the $theurl array for "mydomain"... AND it assumes the original URL will always be "mydomain" (it may be, but buildakicker hasn't responded yet). Mine ignores the original host name altogether (it doesn't matter) and appends the directory path to the final domain name. One fix to my code... should be parse_url, with the underscore.