0

When I include php, css, graphic files etc., I tend to prefer using a local address, as this is easier to work with on local development (eg '../gfx/logo.png').

Nevertheless, this can cause problems if the file that triggers the include request is loaded from different location. At that case a local address include won't work, and therefore in these kind of files I use remote url address (eg 'http://site.com/gfx/logo.png').

A disadvantage of using a full path ('/root/mysite/gfx/logo.png') being on a shared server, this path is a bit long, and repeating it for every include is kind of messing the code.

Which is the most efficient, elegant way?

Roy
  • 1,307
  • 1
  • 13
  • 29

2 Answers2

0

If you are having problems using relative urls just use the full url path i.e. http://example.com/images/test.png :) There is no need to include the server path (and this is more dangerous too!)

ABC
  • 718
  • 8
  • 23
0

you can try the '<%=VirtualPathUtility.ToAbsolute("~/gfx/logo.png") %>' This helps me to test everything on my localhost as-well-as my QA server without worrying about changing the urls. hope it helps

Scorpio
  • 1,151
  • 1
  • 19
  • 37