我知道在htaccess中但是如何使用web.config Rules属性重写站点地图的url。我尝试过以下方法,但都没有效果
<rule name="sitemap URL" patternSyntax="ECMAScript" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^/sitemap.xml$" /> - Not working
<add input="{HTTP_HOST}" pattern="^domain.com/sitemap.xml$" /> - Not working
<add input="{HTTP_HOST}" pattern="^www.domain.com/sitemap.xml$" /> - Not working
</conditions>
<action type="Rewrite" url="foldername/sitemaps/sitemap-a.xml" />
</rule>
也尝试了
<rule name="sitemap URL" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^.+\.(local|www)?(domain).+\.(?:xml)$" />
<action type="Rewrite" url="foldername/sitemaps/sitemap-a.xml" />
</rule>
答案 0 :(得分:9)
这对我有用。
<rule name="SiteMap" patternSyntax="Wildcard" stopProcessing="true">
<match url="sitemap.xml" />
<action type="Rewrite" url="sitemap.ashx" appendQueryString="false" />
</rule>