Forum Moderators: coopster
Currently I resolve this on case by case basis but it gets more difficult to trace out all intended event triggers on the original code and change relative links to absolute. Maybe there is some standard PHP cURL class or Apache modules (mode_proxy+mod_proxy_http maybe) that can rewrite relative links to absolute when relative link is in a java script and resource file actually has to be accessed on another domain or subdomain?
I'll appreciate if you share your experience.
when relative link is in a java script and resource file actually has to be accessed on another domain or subdomain
It cannot be a relative link at that point. Unless the JavaScript file itself was pulled from another domain/subdomain, then I understand the predicament. However, if you are using curl to get that page, then you already know the absolute path, including schema, and you can get that by using the parse_url function.
However, if you are using curl to get that page, then you already know the absolute path, including schema, and you can get that by using the parse_url function.
Yes, I'm using php curl to get that page. Yes, I can parse_url the absolute path that curl uses as a target URL. And can get the [scheme] and [host] components of the associative array this function returns. But how do I define that a certain string within javascript tags is actually a relative URL link? I need to get all those relative links in an array and the rest is easy, just change them by concatenated scheme.host.relative_link string?
If SE's are so good recently in indexing javascript links (including relative links) then there must be some quite secure method of defining such strings as links?
I need to get all those relative links in an array and the rest is easy, just change them by concatenated scheme.host.relative_link string?
If that is a question, yes, you have answered your own question correctly. That is how you do it today using curl when crawling/parsing a document's href and src attributes.
But how do I define that a certain string within javascript tags is actually a relative URL link?
Start with the same concept, which attributes and/or event handlers provide potential relative links?