0

I'm dealing with a web-service that serves video files (host). They provide you with a Guid which is used in an embed code (link to js file).

Their URL's are structured like this:

http://www.foo.com/34534525lsjda345435/script.js

Somehow, the script.js parses this URL and retrieves the variable. Can someone clue me in how this is done?

What kind of script runs on the server-side to respond to these requests? After all, the string in the URL doesn't really refer to a real directory, or does it?

Any help/insights would be appreciated.

2 Answers 2

1

The server could be doing URL Rewriting. A rewrite engine would convert that URL to point to some server side script that returns dynamically generated JavaScript. The rewritten URL could look something like this:

http://www.foo.com/some-server-side-script.php?id=34534525lsjda345435

Sign up to request clarification or add additional context in comments.

Comments

0

They most likely rewrite the URL and pass that ID to a script which generates the Javascript -- by generate I mean embed any video-specific data into the javascript. A javascript file doesn't have knowledge of the URL where it resides, only the URL of the window or frame where it's being loaded.

foo.com/$1/script.js -> foo.com/gen_script?id=$1 

Where foo.com/gen_script?id=$1 is the script that actually generates that file.

If they use something like mod_rewrite, you would find something like the following in their config file:

RewriteRule ^(.*)/script\.js$ http://foo.com/gen_script?id=$1 

1 Comment

Well after a couple of weeks breaking my head I actually arrived at the same conclusion! :) thanks for the help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.