I had an issue with stylesheets and images as well.
I did not want to use the Base Href solution and fixed my problem with updating my relative paths to begin with a single slash.
My Setup
nopCommerceStore is used to build a webshop.
nopCommerce uses the 'UrlRewritingNet.UrlRewrite' library to handle url rewriting.
nopCommerce uses the ASP.NET Themes and Skins for defining the apearance of the webshop.
On the server side you have the following folder structure:
root
root/App_Themes/darkOrange/base.css
root/App_Themes/darkOrange/cart-checkout-order.css
root/App_Themes/darkOrange/category.css
root/App_Themes/darkOrange/css/ie6.css (this file was eventually removed)
root/App_Themes/darkOrange/img/transparent_image_example.png
root/css/ie6.css
root/MasterPages/Root.Master
root/Default.aspx root/Category.aspx
When landing on the default page (browser requests http;//yourstore/default.aspx) your html source will contain the following html code:
<link href="App_Themes/darkOrange/base.css" type="text/css" rel="stylesheet" />
<link href="App_Themes/darkOrange/cart-checkout-order.css" type="text/css" rel="stylesheet" />
<link href="App_Themes/darkOrange/category.css" type="text/css" rel="stylesheet" />
...
The browser will fire the following requests:
http;//yourstore/App_Themes/darkOrange/base.css
http;//yourstore/App_Themes/darkOrange/cart-checkout-order.css
http;//yourstore/App_Themes/darkOrange/category.css
...
When clicking on the category 'Books', the browser requests http;//yourstore/Category/29-books.aspx) your html source will contain the following html code:
<link href="../App_Themes/darkOrange/base.css" type="text/css" rel="stylesheet" />
<link href="../App_Themes/darkOrange/cart-checkout-order.css" type="text/css" rel="stylesheet" />
<link href="../App_Themes/darkOrange/category.css" type="text/css" rel="stylesheet" />
The browser will fire the following requests:
http;//yourstore/Category/../App_Themes/darkOrange/base.css
http;//yourstore/Category/../App_Themes/darkOrange/cart-checkout-order.css
http;//yourstore/Category/../App_Themes/darkOrange/category.css
Transparent PNG in IE6
So far everything runs fine. To make the appearance consistant across all browsers a IE6 specific stylesheet needed to be loaded.
I learned two important things:
Do not add the stylesheet to the 'App_Themes' folder but place it in a separate folder.
If referencing images, use relative paths that begin with a single slash.
Stylesheets and the 'App_Themes' folder:
To apply a specific layout to pages that are viewed in IE6, I created a new stylesheet and placed it in the 'root/App_Themes/darkOrange/css' folder.
In the file 'root/MasterPages/Root.Master' I added the following lines of html code:
<!--[if IE 6]>
<link rel="stylesheet" type="text/css" media="screen" href="/css/ie6.css" />
<![endif]-->
When a Css file is placed in the 'App_Themes folder or in a subfolder within 'App_Themes' it will automatically be referenced.
This caused undesired behavior in non-IE6 browsers. The IE6 layout was applied to the page and messed up the appearance of the page.
When landing on the default page (browser requests http;//yourstore/default.aspx) the server will parse the request.
The resulting html source will contain the following html code:
<!--[if IE 6]>
<link rel="stylesheet" type="text/css" media="screen" href="/css/ie6.css" />
<![endif]-->
But also the html contains the following line:
<link href="App_Themes/darkOrange/css/ie6.css" type="text/css" rel="stylesheet" />
All browsers will fire the following request:
http;//yourstore/App_Themes/darkOrange/css/ie6.css
IE6 will fire an extra request (file will be retrieved from the IE cache):
http;//yourstore/App_Themes/darkOrange/css/ie6.css
This was undesired behaviour so I had to replace the 'ie6.css' file to a new folder. It is now placed in 'root/css/ie6.css'.
Referencing images, Url rewriting and relative paths:
To support transparent png images in IE6, the ie6.css file contains some css 'filter' properties.
e.g. One of the div selectors would include the following line of css code:
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled='true', sizingMethod='crop', src='../App_Themes/darkOrange/img/transparent_image_example.png');
When landing on the default page (browser requests http;//yourstore/default.aspx) IE6 would request:
http;//yourstore/img/transparent_image_example.png
When clicking on the category 'Books', the browser requests http;//yourstore/Category/29-books.aspx) IE6 would request:
http;//yourstore/img/transparent_image_example.png
Both resulting in 'The page cannot be found' (HTTP/1.1 404 Not Found).
After replacing:
'../App_Themes/darkOrange/img/transparent_image_example.png'
With:
'/App_Themes/darkOrange/img/transparent_image_example.png'
Everything worked fine.
This is because the relative path begins with a single slash.
The browser will interpret the url in the following way:
Does it start with 'http;//'? If yes, it must be an absolute path; If no, it must be a relative path.
Relative paths:
Does it start with a single slash? If yes, it must be a 'absolute-path reference'; If no, it must be a 'relative-path reference'
note: see Section 5 'Relative URI References', in the document "Uniform Resource Identifiers (URI): Generic Syntax" (http://www.ietf.org/rfc/rfc2396.txt).
In case of url rewritten pages:
The browser will fail when using 'relative-path references' (e.g. 'http;//yourstore/Category/29-books.aspx' and '../App_Themes/darkOrange/img/transparent_image_example.png').
The browser will succeed when using 'absolute-path references' (e.g. 'http;//yourstore/Category/29-books.aspx' and '/App_Themes/darkOrange/img/transparent_image_example.png').