how to make all links on a page absolute?
i have bunch of htmls on my disk and I know absolute adress of each of them, now I want to make every instance of src="", href="" inside a tags like a, script, img, iframe etc. to point to absolute patch if the given path is relative.
I do not know what is the fastest way to do it, by regex, preg_matc开发者_如何转开发h_all etc ? I want this script to have awareness of paths like "../../somefile.html".
I think you will need a combination of regex and script, since I don't think a regex can do this on it's own
However if you get a regex to pull out a HREF with ../ then use script to count back the folders and replace with your required URL.
精彩评论