문제

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?

도움이 되었습니까?

해결책

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" />

다른 팁

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/

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top