2017-10-03 5 views
1

ユーザーフレンドリーなURLを作成しようとしていますが、複数のルールが競合しているようです。iis urlユーザーフレンドリーなURLを書き直す複数のルールが矛盾しwokrsではない

私は好き、それを作成する必要があります。

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="^([^=&amp;]+)=([^=&amp;]+)$" /> 
    </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="^([^=&amp;]+)=([^=&amp;]+)$" /> 
    </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にリダイレクトします。だから、私は$var is undefinedのエラーを受け取り、結果はページに表示されませんが、URLは異なります。

私は

www.example.com/destination/abc 

www.example.com/river/cde 

が必要しかし、何とかちょうど1つのルールにリダイレクトするように思えるこの結果を得ます。

してくださいすべてのフィードバックは、私は多くの同じ記事をチェックしますが、あなたのクエリはPHPのファイル名など

river.php?river=abcdestination.php?destination=abc

と同じであるならば、あなたのようなあなたのコードを変更することができます解決策に

答えて

1

を見つけることができますこれは:

<action type="Rewrite" url="{R:1}.php?{R:1}={R:2}" /> 

URLは仕事のためにあなたのファイル名はquery_stringと同じでなければなりません

+0

ありがとうございます – Maria

関連する問題