Question

I've written URL using Helicon ISAPI Rewrite v3 for following:

www.foo.com/tags/tag1 --> www.foo.com/Pages/Articles/ArticleListing.aspx?tags=tag1

But the .css, .js i've refered are being accessed by browser as

www.foo.com/tags/tag1/style.css
www.foo.com/tags/tag1/myjs.js

but these files are located as

www.foo.com/css/style.css
www.foo.com/js/myjs.js

Without hardcoding the domain name "www.foo.com", how i can achieve wrong referencing?

Was it helpful?

Solution

First, verify that your RewriteRule is not including more than just tags. A simple fix might be to put this RewriteCond on the line before your RewriteRule.

RewriteCond %{REQUEST_FILENAME} !(.js|.css|.gif|.jpg)

Your stylesheet link tag can be simply:

  <link href="/css/style.css" rel="stylesheet" type="text/css" />

OTHER TIPS

One trick for handling CSS and other static files i.e. images and javascript, is to include a base tag in the head section of your page e.g.

That way, all your CSS paths, etc. will be resolved relative to the href in the base tag.

For more info you can check this post: http://chriscavanagh.wordpress.com/2008/11/06/aspnet-routing-just-enough-rope/

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