views:

43

answers:

2

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_match_all etc ? I want this script to have awareness of paths like "../../somefile.html".

A: 

use htaccess file. The best way.

Make a php file which replaces url via. matching substring.

Set this file in include path using htaccess.

seed_of_tree
I'm not sure .htaccess can achieve what he is looking for
Toby Allen
Now explained the way to do.
seed_of_tree
A: 

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.

Toby Allen