![](/img/trans.png)
[英]IIS 7.5 URL Rewrite: Is there a better way to rewrite / combine multiple rules
[英]IIS 7.5 URL Rewrite not working? help please
我正在嘗試重寫URL,因此它采用了my.site.com等URL,並將其重寫為“ Http:// localhost:8080”。 我一直在獲取默認主頁,而不是被重定向。 我已將重寫配置如下:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="mysite">
<match url="(my.+)" />
<action type="Rewrite" url="http://localhost:8080" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
我很茫然,我做錯了什么嗎?
任何幫助將不勝感激。
干杯傑夫
目前尚不清楚要實現的目標和原因,但並不是100%明確,但是由於涉及到localhost,您似乎不想重寫,但可能要執行http redirect 。 重寫意味着您的請求URL已被更改為另一個URL,例如index_foo.htm可以重寫為index.aspx?what = foo。
但是您想更改域,因此需要重定向 。 嘗試:
<system.webServer>
<httpRedirect enabled="true" destination="http://localhost:8080" childOnly="false" />
</system.webServer>
這將保留您調用的任何本地頁面,即my.site.com/foo.htm將被重定向到localhost:8080 / foo.htm。
因為這看起來只是出於開發目的的臨時性任務,所以您可以添加
httpResponseStatus="Temporary"
到httpRedirect(對於不丟失搜索引擎排名可能很重要)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.