[英]Convert htaccess rewrite rule to web.config
我一直在嘗試將.htaccess
規則轉換為web.config
但是沒有運氣,我嘗試了在線工具來做到這一點,並嘗試了一些類似的規則,但是我一無所獲,這就是我得到的:
// .htaccess
RewriteCond %{HTTP_HOST} ^(?:www\.)?oldURL$ [NC]
RewriteRule ^/?e:/folder1/folder2/folder3(/.*)?$ http://newURL$1 [L,NE,R=301,NC]
我在web.config
嘗試了此規則:
<rule name="Redirect files" stopProcessing="true">
<match url="^/?e:/folder1/folder2/folder3(/.*)?$" ignoreCase="true" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTP_HOST}" pattern="^(?:www\.)?oldURL$" />
</conditions>
<action type="Rewrite" url="http://newURL{R:1}" />
</rule>
有人可以告訴我我在這里想念的東西嗎? 謝謝。
我不知道為什么web.config無法重寫URL,但是重定向對我有用,因此我更改了操作行:
<action type="Redirect" url="http://newURL{R:1}" redirectType="Permanent" />
我刪除了條件:
<conditions logicalGrouping="MatchAll">
<add input="{HTTP_HOST}" pattern="^(?:www\.)?oldURL$" />
</conditions>
現在,我所有的文件都使用新的URL服務器存儲。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.