Mod rewrite iis url重写用户友好的url多个规则冲突而不是WOKR
我一直在尝试创建用户友好的URL,但多个规则似乎存在冲突 我需要像这样创建它:Mod rewrite iis url重写用户友好的url多个规则冲突而不是WOKR,mod-rewrite,iis,Mod Rewrite,Iis,我一直在尝试创建用户友好的URL,但多个规则似乎存在冲突 我需要像这样创建它: www.example.com/destination/abc www.example.com/river/cde 使用此代码: <rules> <rule name="RedirectUserFriendlyURL3" stopProcessing="true"> <match url="^destination\.php$" /> <conditio
www.example.com/destination/abc
www.example.com/river/cde
使用此代码:
<rules>
<rule name="RedirectUserFriendlyURL3" stopProcessing="true">
<match url="^destination\.php$" />
<conditions>
<add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
<add input="{QUERY_STRING}" pattern="^([^=&]+)=([^=&]+)$" />
</conditions>
<action type="Redirect" url="{C:1}/{C:2}" appendQueryString="false" />
</rule>
<rule name="RewriteUserFriendlyURL3" stopProcessing="true">
<match url="^([^/]+)/([^/]+)/?$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="destination.php?{R:1}={R:2}" />
</rule>
<rule name="RedirectUserFriendlyURL4" stopProcessing="true">
<match url="^river\.php$" />
<conditions>
<add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
<add input="{QUERY_STRING}" pattern="^([^=&]+)=([^=&]+)$" />
</conditions>
<action type="Redirect" url="{C:1}/{C:2}" appendQueryString="false" />
</rule>
<rule name="RewriteUserFriendlyURL4" stopProcessing="true">
<match url="^([^/]+)/([^/]+)/?$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="river.php?{R:1}={R:2}" />
</rule>
</rules>
但不知何故,它似乎只是在1规则重定向
请提供任何反馈,我检查了许多相同的帖子,但如果您的查询与php文件名相同,我可以找到解决方案
river.php?river=abc
和destination.php?destination=abc
然后您可以像这样更改代码:
<action type="Rewrite" url="{R:1}.php?{R:1}={R:2}" />
所以,您的文件名应该与url中的查询字符串相同才能工作
<action type="Rewrite" url="{R:1}.php?{R:1}={R:2}" />