By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,401 Members | 1,679 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,401 IT Pros & Developers. It's quick & easy.

Adding a base URL to links - please help

P: n/a
Hi there,

I'm new to the world of PHP, so forgive me if this is a daft question.
I've written a script which pulls some headlines from a remote site and
displays them on my server. Trouble is, all of the links are relative
and I need some way of adding the "http://www.foobar.com/" to the start
of these links.

How do I go about doing it?

Regards,

Kevin

Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Kevin,
I'm new to the world of PHP, so forgive me if this is a daft question.
I've written a script which pulls some headlines from a remote site and
displays them on my server. Trouble is, all of the links are relative
and I need some way of adding the "http://www.foobar.com/" to the start
of these links.

How do I go about doing it?


Look into regular expressions. Search for the <a href=""> tag and check
the contents inside. Then do a replace on the link it self.

I would write it out for you but that doesn't help you to learn it yourself.

A good starting point for regular expressions is: http://www.regexplib.com
Mike
Jul 17 '05 #2

P: n/a
Just add a <base url="http://..."> tag in the head section.

Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.