473,671 Members | 2,290 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Relative URL

Hi

How do I refernece links so that they work on both my development and live
servers? On my development machine, my web site exists in a virtual
directory so a relative link such as '/images/image1.gif' that works on my
live server doesn't work (because it points back to the root of my website,
not that of my virtual directory)?

Cheers

Alan

Nov 18 '05 #1
4 1420
It works for me both in server-side and my IIS on pc:
<img src='images/image1.gif'>
remove the first "/" and try again, if you've images folder in one level
upper than your files, it works.

Another thing, perhaps you didn't added the file to your project.
if you use visual studio:
select your "images" folder in solotion explorer, right-click|Add|Exist ing
Item , and then choose your images you want to add to yout project.
"Alan Roberts" <al**@statistix l.co.uk> wrote in message
news:ek******** ******@TK2MSFTN GP09.phx.gbl...
Hi

How do I refernece links so that they work on both my development and live
servers? On my development machine, my web site exists in a virtual
directory so a relative link such as '/images/image1.gif' that works on my
live server doesn't work (because it points back to the root of my
website,
not that of my virtual directory)?

Cheers

Alan

Nov 18 '05 #2
Hi Saber

Thanks for the advice but this doesn't work for controls etc. I have a
number of controls that use graphics. These controls can occurr on pages at
any level within my site so the relative path to the images folder from them
is different. I need some way to indicate paths relative to the application
root rather than the web server route.

Cheers

Alan

"Saber" <saber[--AT--]maghalat.com> wrote in message
news:en******** ******@TK2MSFTN GP10.phx.gbl...
It works for me both in server-side and my IIS on pc:
<img src='images/image1.gif'>
remove the first "/" and try again, if you've images folder in one level
upper than your files, it works.

Another thing, perhaps you didn't added the file to your project.
if you use visual studio:
select your "images" folder in solotion explorer, right-click|Add|Exist ing
Item , and then choose your images you want to add to yout project.
"Alan Roberts" <al**@statistix l.co.uk> wrote in message
news:ek******** ******@TK2MSFTN GP09.phx.gbl...
Hi

How do I refernece links so that they work on both my development and live servers? On my development machine, my web site exists in a virtual
directory so a relative link such as '/images/image1.gif' that works on my live server doesn't work (because it points back to the root of my
website,
not that of my virtual directory)?

Cheers

Alan



Nov 18 '05 #3
Use "~". ~/images/image1.gif

You will have to use server tags though. Or perhaps the ResolveURL method.

Bob Lehmann

"Alan Roberts" <al**@statistix l.co.uk> wrote in message
news:ek******** ******@TK2MSFTN GP09.phx.gbl...
Hi

How do I refernece links so that they work on both my development and live
servers? On my development machine, my web site exists in a virtual
directory so a relative link such as '/images/image1.gif' that works on my
live server doesn't work (because it points back to the root of my website, not that of my virtual directory)?

Cheers

Alan

Nov 18 '05 #4
Thanks guys. This seems to work got img tags as well as long as i include
runat=server in them. Is there a similar shortcut that can use within CSS
files?

Alan

"Bob Lehmann" <no****@dontbot herme.zzz> wrote in message
news:ui******** ******@TK2MSFTN GP11.phx.gbl...
Use "~". ~/images/image1.gif

You will have to use server tags though. Or perhaps the ResolveURL method.

Bob Lehmann

"Alan Roberts" <al**@statistix l.co.uk> wrote in message
news:ek******** ******@TK2MSFTN GP09.phx.gbl...
Hi

How do I refernece links so that they work on both my development and live servers? On my development machine, my web site exists in a virtual
directory so a relative link such as '/images/image1.gif' that works on my live server doesn't work (because it points back to the root of my

website,
not that of my virtual directory)?

Cheers

Alan



Nov 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
4108
by: jason | last post by:
Can anyone help me find a solution to quickly working out relative paths to a folder in the root of my server... Although it easy when you go - say - two levels down: .../includes it becomes increasingly difficult to ball park the folder when you go deeper and wider down:
2
12024
by: Catherine Lynn Wood | last post by:
I need to know how to overlap DIV content within 'relative' associated rendering. I am building div layers in the middle of a page and when I set positioning to absolute in the CSS, it references back to 0,0 on the entire page. If I set it to relative, the div layers will not overlap as needed. I prefer to avoid javascripting an 'innerHTML' re-write of a single div and would instead like to build two layers that can reside at the same...
3
19767
by: Markus Ernst | last post by:
Hello Reading the follwing document: http://www.w3.org/TR/WD-positioning-970131#In-flow it seems very clear that position:relative should be relative to the parent element. So in the following test case element1 and element2 should be placed side by side inside a centered white container element: http://www.markusernst.ch/test.htm
6
11761
by: openleren | last post by:
Hi all, how can I use a relative path in my web.config file for an Access db?: Instead of using <configuration> <appSettings> <add key="conAccess" value="microsoft.jet.oledb.4.0;data source=c:/Inetpub/MyApp/data/database.mdb" /> ...
4
4062
by: dropdeadster | last post by:
Trying to line up a tic-tac-toe board type grid of images using style= tags to <img inside a table TD but it's not working, I get more like a set of steps, can I get an explanation of what's wrong with this and how to do it correctly?: <table border="1"> <tr> <td valign="top" align="left">
8
2596
by: JJ | last post by:
I'm confused about paths. I have a functionn that uses the mappath method, which I think requires a virtual path (is that the same as a relative path?). But this doesn't always work as the path can take the form of the following: 1. /directory/images/xyz.gif (works fine) 2. http://localhost:1234/www.mytestwebsite.com/directory/images/xyz.gif (doesn't work) 3. http:///www.someremotesite.com/directory/images/abc.gif (doesn't work)
12
2730
by: Alan Isaac | last post by:
Are relative imports broken in 2.5? Directory ``temp`` contains:: __init__.py test1.py test2.py File contents: __init__.py and test2.py are empty test1.py contains a single line::
15
6458
by: Lars Eighner | last post by:
Aside from the deaths of a few extra electrons to spell out the whole root relative path, is there any down side? It seems to me that theoretically it shouldn't make any difference, and it would make it much easier to slap modualar blocks of markup into page frameworks, which may change and so forth. And the few extra bytes, which even for a fairly large site would not amount to as many bytes as are in a fairly small low-res image, should...
0
1391
by: Kay Schluehr | last post by:
Since their introduction in Python 2.5 I only reviewed the new "relative import" notation briefly by reading the "What's new in Python 2.5" article. Now I wanted checkout if I get comfortable with them. Opening the tutorial I found following notice ( 6.4.2 ): "Note that both explicit and implicit relative imports are based on the name of the current module. Since the name of the main module is always "__main__", modules
0
1491
by: Gabriel Genellina | last post by:
En Sat, 18 Oct 2008 05:52:04 -0300, Stef Mientki <stef.mientki@gmail.com> escribió: Why don't you let the caller tell you its own location, using __file__? The above code is too much magic for me. Yes.
0
8473
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8390
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8819
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8597
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7428
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6222
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5692
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4402
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2048
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.