Mod rewrite 基于工作web.config的简单mod重写

Mod rewrite 基于工作web.config的简单mod重写,mod-rewrite,web-config,iirf,Mod Rewrite,Web Config,Iirf,对于导航到link.html的人来说,这是一个简单的重定向,可以重定向到index.php/link/,同时保持所有查询字符串的完整性 在web.config文件中使用IIS7的环境中,下面的功能非常有效 <rule name="Rewrite for link.html"> <match url="link.html" /> <action type="Rewrite" url="index.php/link/" /> </rule&g

对于导航到link.html的人来说,这是一个简单的重定向,可以重定向到index.php/link/,同时保持所有查询字符串的完整性

在web.config文件中使用IIS7的环境中,下面的功能非常有效

<rule name="Rewrite for link.html">
    <match url="link.html" />
    <action type="Rewrite" url="index.php/link/" />
</rule>
<rule name="Rewrite CI Index">
    <match url=".*" />
    <conditions>
        <add input="{REQUEST_FILENAME}" pattern="css|js|jpg|jpeg|png|gif|ico|htm|html|ttf|eot" negate="true" />
        <add input="{REQUEST_FILENAME}" pattern="admin.php" negate="true" />
        <add input="{REQUEST_FILENAME}" pattern="index.php" negate="true" />
    </conditions>
    <action type="Rewrite" url="index.php/{R:0}" />
</rule>
问题是如何使link.html的重写适应这种类似apache的语法


TIA获取任何帮助。

只需在RewriteCond/RewriteRule块之前添加重定向规则:

RedirectRule ^link.html(.*)$ /index.php/link/$1

把这个放在上面工作:RewriteCond%{REQUEST_FILENAME}-f RewriteCond%{REQUEST_URI}^/link\.html RewriteRule^.*$/index.php/link[L]我以为您想重定向,而不是重写。顺便说一句,您实际上不需要重写cond,简单地说就是重写规则^/link\.html$/index.php/link[L,I](我建议也添加
[I]
标记以进行不区分大小写的匹配)。
RedirectRule ^link.html(.*)$ /index.php/link/$1