URL重写 [英] URL Rewriting

查看:105
本文介绍了URL重写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的URL中使用regx在我的asp.net应用程序重写

i am using URL rewriting in my asp.net application using regx

虚拟URL是

/ProductDatabaseCMS/(?<category>\w*)/Product/(?<product>\w*)\.aspx

原始URL是

/ProductDatabaseCMS/Product.aspx?PROD_ID=${product}

应用程序路径为〜/ ProductDatabaseCMS

我的应用程序有一个使用样式表母版页和路径是

my application has master page that uses style sheet and the path is

~/App_Themes/Styles/Style_Sheet.css

我请求的URL

i am requesting the URL

/ProductDatabaseCMS/(?<category>\w*)/Product/(?<product>\w*)\.aspx

使用超链接控制,但在这种情况下样式表不工作的这个页面,因为它走的路径应用程序的网页之一

from one of the webpage of application using Hyperlink control but in that case stylesheet is not working for this page Because it is taking path

~/ProductDatabaseCMS/(?<category>\w*)/Product/App_Themes/Styles/Style_Sheet.css

我有什么在这种情况下做的。

what i have to do in this case.

推荐答案

如果您使用的是相对URI引用外部样式表,你必须要考虑这一点:相关的URI总是从基本URI是的URI的解决如果没有特别声明的现有资源。

If you use a relative URI to reference the external stylesheet, you have to consider this: Relative URIs are always resolved from a base URI which is the URI of the current resource if not declared otherwise.

所以,如果你要求 /富/条并有一个相对的URI引用 CSS / baz.css 中HTML文件,它会被解析为 /foo/css/baz.css /富/条是基URI。

So if you request /foo/bar and there is a relative URI reference css/baz.css in the HTML document, it would be resolved to /foo/css/baz.css as /foo/bar is the base URI.

要解决这个问题,你有两种选择:

To solve this problem you have two options:


  1. 使用绝对URI或至少绝对路径来引用资源(例如 /App_Themes/Styles/Style_Sheet.css )或

  2. 使用 BASE设置一个合适的基准URI HTML元素(如&LT;基本href =/&GT; ),使每一个相对URI从该新基地解析URI。

  1. use absolute URIs or at least absolute paths to reference the resources (e.g. /App_Themes/Styles/Style_Sheet.css), or
  2. set a suitable base URI using the BASE HTML element (e.g. <base href="/">) so that every relative URI is resolved from that new base URI.

这篇关于URL重写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆