2015-06-11 5 views
5

पकड़ने मैं कई .php फ़ाइलों (एक से अधिक 10)आईआईएस समस्याओं पुनर्लेखन - किसी फ़ोल्डर में सभी .php फ़ाइलों

aaa.php 
bbb.php 
ccc.php 
ddd.php 
index.php 

क्या मैं प्राप्त करने के लिए ठीक से फिर से लिख रहा है उन्हें इतनी के रूप में करने के लिए कोशिश कर रहा हूँ दोस्ताना यूआरएल। पुनर्लेखन कर रहे हैं: मैं प्राप्त

www.domain.com/data -> www.domain.com/data/index.php 
www.domain.com/data/ -> www.domain.com/data/index.php 
www.domain.com/data/aaa -> www.domain.com/data/aaa.php 
www.domain.com/data/aaa/ -> www.domain.com/data/aaa.php 
www.domain.com/data/aaa/chapter1 -> www.domain.com/data/aaa.php?c=chapter1 

www.domain.com/data/bbb -> www.domain.com/data/bbb.php 
www.domain.com/data/bbb/ -> www.domain.com/data/bbb.php 
www.domain.com/data/bbb/chapter1 -> www.domain.com/data/bbb.php?c=chapter1 

... 

निम्नलिखित नियमों का उपयोग करके क्या मैं एक php फ़ाइलें

<rule name="Friendly1" stopProcessing="true"> 
    <match url="^aaa$" /> 
    <conditions> 
     <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> 
     <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> 
    </conditions> 
    <action type="Rewrite" url="aaa.php" appendQueryString="false" /> 
</rule> 
<rule name="Friendly2" stopProcessing="true"> 
    <match url="^aaa/$" /> 
    <conditions> 
     <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> 
     <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> 
    </conditions> 
    <action type="Rewrite" url="aaa.php" appendQueryString="false" /> 
</rule> 
<rule name="Friendly3" stopProcessing="true"> 
    <match url="^aaa/(.+)\.(.+)$" /> 
    <conditions> 
     <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> 
     <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> 
    </conditions> 
    <action type="Rewrite" url="{R:1}.{R:2}" appendQueryString="false" /> 
</rule> 
<rule name="Friendly4" stopProcessing="true"> 
    <match url="^aaa/(.+)$" /> 
    <conditions> 
     <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> 
     <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> 
    </conditions> 
    <action type="Rewrite" url="aaa.php?c={R:1}" appendQueryString="false" /> 
</rule> 

काम करता है यही कारण है कि के लिए चाहते हैं। हालांकि यह कुशल नहीं है और फ़ोल्डर में प्रत्येक php फ़ाइल के लिए उन नियमों को प्रतिलिपि बनाने में त्रुटि त्रुटि है।

तो, मैं (। +) नियमों में साथ aaa का आदान प्रदान के बारे में सोचा है और यह कुछ मामलों के लिए काम नहीं करता।

<rule name="Friendly1" 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="{R:1}.php" appendQueryString="false" /> 
</rule> 
<rule name="Friendly2" 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="{R:1}.php" appendQueryString="false" /> 
</rule> 
<rule name="Friendly3" 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="{R:1}.php/{R:2}.{R:3}" appendQueryString="false" /> 
</rule> 
<rule name="Friendly4" stopProcessing="true"> 
    <match url="^(.+)/(.+)$" ignoreCase="true"/> 
    <conditions> 
     <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> 
     <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> 
    </conditions> 
    <action type="Rewrite" url="{R:1}.php?c={R:2}" appendQueryString="false" /> 
</rule> 

यह निम्नलिखित मामलों के लिए काम करता है:

www.domain.com/data -> www.domain.com/data/index.php 
www.domain.com/data/ -> www.domain.com/data/index.php 
www.domain.com/data/aaa -> www.domain.com/data/aaa.php 

यह निम्नलिखित मामलों के लिए काम नहीं करता:

www.domain.com/data/aaa/ -> www.domain.com/data/aaa.php 
www.domain.com/data/aaa/chapter1 -> www.domain.com/data/aaa.php?c=chapter1 

जो मामलों के लिए मैं एक "नहीं मिला"। क्या मैं कुछ गलत कर रहा हूं? इसे कैसे हल किया जा सकता है ?

आईआईएस = 7.5+

अग्रिम धन्यवाद।

+0

आप काम कर रहे मामलों में भी सूची सकते हैं? –

+0

@CyrilDurand मैंने उन्हें अब जोड़ा – MIrrorMirror

उत्तर

1

कैसे इस बारे में ...

<rewrite> 
    <rules> 
     <rule name="Friendly1" stopProcessing="true"> 
      <match url="^data/([-a-zA-Z0-9]*)/[-a-zA-Z0-9]*)$" ignoreCase="true" /> 
      <action type="Rewrite" url="data/{R:1}.php?c={R:2}" /> 
     </rule> 
     <rule name="Friendly2" stopProcessing="true"> 
      <match url="^data/([-a-zA-Z0-9][-a-zA-Z0-9]*)$" ignoreCase="true" /> 
      <action type="Rewrite" url="data/{R:1}.php" /> 
     </rule> 
     <rule name="Friendly3" stopProcessing="true"> 
      <match url="^data(/.*)$" ignoreCase="true" /> 
      <action type="Rewrite" url="data/index.php" /> 
     </rule> 
    </rules> 
</rewrite> 
+0

दुर्भाग्य से काम नहीं कर रहा है – MIrrorMirror

संबंधित मुद्दे