2016-04-03 16 views
0

私はAzureで使用するためにweb.configに変換する必要がある.htaccessファイルがあります。ここでのhtaccessファイルです:.htacessをAzureのweb.configに変換する

Options +FollowSymlinks 
Options -Multiviews 
ErrorDocument 404 /error-404 
RewriteEngine On 
RewriteCond %{REQUEST_FILENAME}.php -f 
RewriteRule !.*\.php$ %{REQUEST_FILENAME}.php [NC,L] 

私は既にweb.configファイルにこれを変換しているが、それは動作しません。 404エラーが検出されません。ここにweb.configがあります:

<?xml version="1.0" encoding="UTF-8"?> 
<configuration> 
    <system.webServer> 
     <rewrite> 
      <rules> 
       <rule name="rule 1C" stopProcessing="true"> 
        <match url="!.*\.php$" ignoreCase="true" /> 
        <action type="Rewrite" url="/%{REQUEST_FILENAME}.php". /> 
       </rule> 
      </rules> 
     </rewrite> 
     <defaultDocument> 
      <files> 
       <add value="test.php" /> 
      </files> 
     </defaultDocument> 
    </system.webServer> 
</configuration> 

このファイルに関するすべては、書き換えを除いてすべて機能します。ちょうどAzureの.phpファイル拡張子なしでページが表示されるのを助ける必要があります。

答えて

0

ErrorDocument 404 /error-404については、下記をご覧ください。

<system.webServer> 
    <httpErrors> 
     <remove statusCode="404" /> 
     <error statusCode="404" path="/error-404" responseMode="ExecuteURL"/> 
    </httpErrors> 
</system.webServer> 

urlの書き換えについては、下記を参照してください。

<configuration> 
    <system.webServer> 
     <rewrite> 
      <rules> 
       <rule name="rule 1C" stopProcessing="true"> 
        <match url="!.*\.php$" /> 
         <conditions logicalGrouping="MatchAll"> 
          <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> 
          <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> 
         </conditions> 
        <action type="Rewrite" url="{R:1}.php" /> 
       </rule> 
      </rules> 
     </rewrite> 
    </system.webServer> 
</configuration> 
関連する問題