我一直在试图创build用户友好的url,但多条规则似乎有冲突。
我需要像这样创build它:
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>
上面的规则不能一起工作,并且两个页面都redirect到第一条规则中设置的那个页面。 所以我得到错误$var is undefined并且在页面上没有结果,但url是不同的。
我得到了我需要的结果
www.example.com/destination/abc www.example.com/river/cde
但不知何故,似乎只是在1规则redirect。
请任何反馈,我检查了许多相同的职位,但可以find一个解决scheme