简体   繁体   English

IIS 7.5 URL重写2.0到HTML页面

[英]IIS 7.5 URL Rewrite 2.0 to HTML Page

I have the following rule: 我有以下规则:

    <rewrite>
        <rules>
            <rule name="FlowURLs">
                <match url="^flows/[_0-9a-zA-Z-]+/[_0-9a-zA-Z-]+/([._0-9a-zA-Z-]+)" />
                <action type="Rewrite" url="music.html?flow={R:1}" />
            <conditions logicalGrouping="MatchAny">
                    <add input="{URL}" pattern="^.*\.(ashx|axd|css|gif|png|jpg|jpeg|js|flv|f4v|html)$" negate="true" />
            </conditions>
            </rule>
        </rules>
    </rewrite>

What I am trying to do is if a url is incoming something like the following: 我正在尝试做的是,如果一个URL传入如下内容:

http://localhost/flows/t/twit_nobone/twit_nobone1354334226132.mp3

I want to rewrite it to: 我想将其重写为:

http://localhost/music.html?id=twit_nobone1354334226132.mp3

The music.html resides in the root and it has a stylesheet, javascript and images. music.html位于根目录中,并且具有样式表,javascript和图像。 The problem I am seeing is that when it rewrites, no images, js or stylesheets are being displayed. 我看到的问题是,当重写时,没有图像,js或样式表被显示。 When I inspect the resources, it looks like the links are now 当我检查资源时,看起来链接现在

http://localhost/flows/t/twit_nobone/twit_nobone1354334226132.mp3/demo.css
http://localhost/flows/t/twit_nobone/twit_nobone1354334226132.mp3/images/screenshot.png

instead of 代替

http://localhost/demo.css
http://localhost/images/screenshot.png

What am I doing wrong? 我究竟做错了什么? I also noticed that the url in the browser never changes to the rewritten one. 我还注意到,浏览器中的URL永远不会更改为重写的URL。

You have to possibilities how to solve this issue. 您必须具有解决该问题的可能性。

1: if you want to keep address like http://localhost/flows/t/twit_nobone/twit_nobone1354334226132.mp3 then make sure that any resources in music.html are linked absolutely so instead of test.css make it /path/to/test.css from root server. 1:如果您想保留类似http://localhost/flows/t/twit_nobone/twit_nobone1354334226132.mp3地址,请确保music.html中的任何资源music.html绝对链接,因此,代替test.css使其成为/path/to/test.css来自根服务器的/path/to/test.css Then it will work. 然后它将起作用。

2: if you prefer address like http://localhost/music.html?id=twit_nobone1354334226132.mp3 EDIT 2:如果你喜欢像地址http://localhost/music.html?id=twit_nobone1354334226132.mp3 编辑

I just found out it is simple - change the action to: 我刚刚发现这很简单-将操作更改为:

<action type="Redirect" redirectType="Found" url="music.html?flow={R:1}" />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM