[英]How to Remove URL from www.example.com/2020/70 to www.example.com in a WordPress website?
[英]URL rewrite rule (iis): redirect ONLY www.example.com and www.example.com/default.aspx
我正在嘗試進行重寫以僅重定向以下頁面:
www.example.com/
www.example.com/default.aspx
我想讓其他所有請求通過。 我知道我已經很近了,但是我似乎無法完美。 在此先感謝您提供的所有幫助!
這是我到目前為止的內容:
<rewrite>
<rules>
<rule name="Base Redirect" stopProcessing="true">
<match url="" />
<conditions>
<add input="{HTTP_HOST}" pattern="www.example.com" ignoreCase="true" negate="false" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="shop.example.com" appendQueryString="true" />
</rule>
<rule name="Default.aspx Redirect" stopProcessing="true">
<match url="default.aspx" />
<conditions>
<add input="{HTTP_HOST}" pattern="www.example.com" ignoreCase="true" negate="false" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="shop.example.com" appendQueryString="true" />
</rule>
</rules>
</rewrite>
問題是它正在發送包含default.aspx的任何內容(/pages/default.aspx等),我們只希望重定向根目錄default.aspx之外的任何內容。
費利克斯
嘗試以下操作(基本上添加“ ^”字符以告訴正則表達式僅在開始時才匹配:
<rule name="Base Redirect" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^$" />
<conditions>
<add input="{HTTP_HOST}" pattern="www.example.com" />
</conditions>
<action type="Redirect" url="http://shop.example.com/" appendQueryString="true" redirectType="Permanent" />
</rule>
<rule name="Default.aspx Redirect" stopProcessing="true">
<match url="^default.aspx" />
<conditions>
<add input="{HTTP_HOST}" pattern="www.example.com" />
</conditions>
<action type="Redirect" url="http://shop.example.com" appendQueryString="true" redirectType="Permanent" />
</rule>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.