Tuesday, April 22, 2014

="/......" vs ="......"

That title is totally not emoticon.


In web development, if a relative URL starts with a slash:

href="/css/bootstrap.css"

It would point back to the root directory of current site, then go down the url, turning into "http://changbai.li/css/bootstrap.css"


But if it doesn't lead with a slash:

href="css/bootstrap.css"

It would start going down the url from the local directory. Say that code is inside changbai.li/work/ninja/index.html, then it'll point to "http://changbai.li/work/ninja/css/bootstrap.css"

I can't exaggerate how useful this is. Or how fun it'll be to mess with developers using this*.


*Don't do that.

No comments:

Post a Comment