473,806 Members | 2,605 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Func to Turn Relative URLs into Abs URLs

tom
hi group,

i desperately need a function that will transform relative URLs to
absolute URLs in the SRC part of <img> tags.

ie:

function makeAbsolute($h tml,$basehref)
{
//if regex match = relative URL ==> return img tag with absolute URL
}

i've scoured Google, PHP.net, PHPClasses.org, etc.., but have been
unable to find such a function.

since i'm an idiot regarding anything concerning RegEx, i've been
unable to write this function on my own.

if anyone has such a function, i'd be very glad if you could please
post it.

Dec 12 '05
10 3164
tom
hey Rajesh,

i just read your post - that's a great link! thanks very much for
posting that.

it's exactly the function i was looking for, and was probably written
by a much better programmer than myself, saving me time, testing and
probably a whole lot of frustration.

Thanks again!

Dec 16 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
9152
by: Joe Cybernet | last post by:
Is there any function for combining an absolute and a relative URL to result in an absolute URL? Like if I have http://www.domain.com and "../images/1.jpeg" it will evaluate to http://www.domain.com/images/1.jpeg. I know WinInet for windows has a function that does this called InternetCombineUrl, I just need the same function in PHP
2
2532
by: twells | last post by:
Anyone know of a site that gives all of the syntax of relative addressing for URLS? for example: /, ./, ../, etc. Thanks!
24
4503
by: sinister | last post by:
After doing a websearch, it appears that it's OK to omit the "http:" to form a relative URL. Are there any pitfalls to this? For example, if there is a page http://www.domain1.com/page1.html with a link to http://www.domain2.com/page2.html you can abbreviate the second link as //www.domain2.com/page2.html
1
1572
by: MattC | last post by:
I have the following in the Page_Error method of my base class for my aspx pages. public void Page_Error(Object sender, EventArgs e) { Server.Transfer(Request.ApplicationPath + "/Error.aspx"); } This works fine, however Error.aspx has some images on it that are document relative, but if a page causes an error that is not in the same path as
0
1302
by: Paul Hatcher | last post by:
I'm using a url rewriting mechanism to make my site's urls more search-engine/user-friendly, so we have http://www.mysite.com/links/1023.apx which is actually internally mapped to http://www.mysite.com/links.aspx?link=1023. This works fine and makes the site look a lot cleaner. The problem I'm having is with controls on the target page. I render all the urls as root relative so that I'm independent of whether I'm a root web or an...
9
1811
by: Paul Hatcher | last post by:
Sorry to post this again - I didn't use my MSDN alias previously... I'm using a url rewriting mechanism to make my site's urls more search-engine/user-friendly, so we have http://www.mysite.com/links/1023.apx which is actually internally mapped to http://www.mysite.com/links.aspx?link=1023. This works fine and makes the site look a lot cleaner. The problem I'm having is with controls on the target page. I render all the urls as root...
0
1118
by: Flip | last post by:
I am retrieving a web page and then taking an inside table to display as an RSS feed. However, there are some relative URLs in there. Of course they work perfectly fine when using IE and navigating to the page. However when I scrape the html out, and load into a temp file, they longer work due to the relative urls. Is there an easy (ie a method to run over the html table or the request) to transform the relative URLs to absolute ones?...
5
2168
shishisu
by: shishisu | last post by:
I figure this might be a fun challenge to some of you out there... I appreciate all the help. Thanks in advance. Here we go... I have 2 web page (on different servers) I am working on. Here, we'll call them Page-A and Page-B. I want to save some work by only having to maintain 1 web page and the changes made to source page will get reflect onto the other one. In this case, Page-A is the source and Page-B should just have a content...
15
6472
by: Lars Eighner | last post by:
Aside from the deaths of a few extra electrons to spell out the whole root relative path, is there any down side? It seems to me that theoretically it shouldn't make any difference, and it would make it much easier to slap modualar blocks of markup into page frameworks, which may change and so forth. And the few extra bytes, which even for a fairly large site would not amount to as many bytes as are in a fairly small low-res image, should...
0
9719
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10623
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10371
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9192
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6877
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5546
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4330
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3852
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3010
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.