Question

So I have a website setup on windows server 2008 R2 IIS 7.5 deployed to a virtual directory we will call "virtdir".

Browsing to http://localhost/virtdir/default.aspx works fine...

I have a domain name setup that redirects to the virtdir.

So http://example.com essentially displays same thing I see above at http://localhost/virtdir/default.aspx

When browsing straight to http://example.com and looking at it through chromes web developer tools It displays several 404 errors telling me it cant find .js and .css files referenced.

However, if I browse to http://example.com/virtdir/default.aspx no errors and the files load fine.

Here is the existing code:

<script type="text/javascript" src="Libraries/dojo/dojo/dojo.js"></script>
<script type="text/javascript" src="jscript/timezone.js"></script>

If I change the code to be prefixed with the folder below using ".."

 <script type="../text/javascript" src="Libraries/dojo/dojo/dojo.js"></script>
 <script type="../text/javascript" src="jscript/timezone.js"></script>

It basically breaks the other way, meaning it will now work browsing straight to http://example.com, but doesn't work browsing to http://example.com/virtdir/default.aspx

How do I get it to work both ways, without hardcoding the entire url http://example.com/virtdir/jscript/timezone.js

Was it helpful?

Solution

You either need to hard code the entire URL, or you need to add virtual directories to your Libraries and jscript folders so that the same path exists in both sites.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top