There's a problem with your regex replacement, Moharo. Check your own example: "index.php" gets matched as \2, so your replacement shows up as:
"http://www.mysite.comindex.php"
There are a bunch of cases you need to test for.
1) Does the link already specify an absolute URL?
(e.g.
http://www.example.com/foo/bar/page.html)
2) Does the link specify an absolute path?
(e.g. /foo/bar/page.html)
3) Does the link specify a path relative to the current script?
a) at or below the current path?
(e.g. page.html, foo/bar/page.html)
b) above or a sibling to the current path?
(e.g. ../page.html, ../foo/bar/page.html)
For 1), do nothing. No replacement necessary.
For 2), simply prepend the host to the path.
for 3), you'll need to calculate the working directory of the currently executing path, and
for a) append the relative url to the working directory.
for b) modify the working directory to reflect the ".."s in the relative path.
Make sense?
Take care,
Nik
http://www.bigaction.org/