PDA

View Full Version : PHP Question...



TheSpaceDude
July 26th, 2001, 16:26
Hello,

I am in the process of making a small proxy server. When I request a page from a remote server, I put the response in the var $data. How would I change all links in $data to this format:

http://www.mydomain.com/proxy.php?url=[LINK HERE]

and also add the host name and directory to the link if it's not already there (eg. change /index.php or filename.php to http://www.domain.com/filename.php)?

Thanks in advance,

Jome
July 26th, 2001, 19:30
Use str_replace and similar functions. Search for http:// and href= in the code. Can't be too hard..

http://php.net/manual

Jome

TheSpaceDude
July 28th, 2001, 18:18
I've tried that, I can add the "/proxy.php?url=" to the links, but I cant get it to add the host name to the link if it is not already there. Any ideas on how I could do this? Anyone? :rolleyes:

niv
July 28th, 2001, 18:25
perhaps you could just use a get method

lucifer
July 30th, 2001, 09:10
regular expressions should do it