我搜索消除html文件扩展名的规则(或一组规则) 但同时能够像下面的例子那样重写浏览器网址:
category1_pageid2.html to categories_page(more seo friendly)
我有IIS 8.5的共享托管环境,IIS_UrlRewriteModule 7.1.1952.0
非常感谢你的帮助
答案 0 :(得分:1)
在IIS中,我创建了一个新规则:
然后在下一个对话框中,我添加了模式 categories_page ,条件为{QUERY_STRING}
匹配模式c=(\d+)&p=(\d+)
(尽管您可能不需要查询字符串 - 根据您的需要自定义)。对于操作,我添加了category{C:1}_pageid{C:2}.html
的重写网址。如果您不需要查询字符串,则可以取消选中附加查询字符串的复选框。
查看该网站的 web.config 文件,我看到下面的XML:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="category-page">
<match url="categories_page" />
<action type="Rewrite" url="category{C:1}_pageid{C:2}.html" />
<conditions>
<add input="{QUERY_STRING}" pattern="c=(\d+)&p=(\d+)" />
</conditions>
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
在我的浏览器中尝试此操作时,当我访问localhost/categories_page?c=1&p=2
时,我会看到category1_pageid2.html页面:
其他选项包括rewrite map - 有关简短说明,请参阅this answer。