2016-06-25 10 views
0

私はAzureにいくつかのPHPアプリケーションを作成しましたが、これは私の初めてのPHPアプリケーション用にIISを使用しています。私はApacheでのURL書き換えに.htaccessを使う方法を知っていますし、問題はありません。しかしAzure IIS上でそれを達成する方法。ここにApache用の.htaccessがあります。URLを書き直すAzure PHP?

の.htaccess

# The Friendly URLs part 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA] 

答えて

1

適切web.configファイル

<?xml version="1.0" encoding="UTF-8"?> 
<configuration> 
    <system.webServer> 
     <directoryBrowse enabled="false" /> 
     <defaultDocument> 
      <files> 
       <clear /> 
       <add value="index.php" /> 
       <add value="Default.htm" /> 
       <add value="Default.asp" /> 
       <add value="index.htm" /> 
       <add value="Default.aspx" /> 
      </files>  
     </defaultDocument> 
     <rewrite> 
      <rules> 
       <rule name="ModX IIS7 Rule 1 (By Simon Fraser)" stopProcessing="true"> 
        <match url=".*" ignoreCase="false" /> 
        <conditions logicalGrouping="MatchAll"> 
         <add input="{HTTP_USER_AGENT}" pattern="^.*internal\ dummy\ connection.*$" /> 
        </conditions> 
        <action type="CustomResponse" statusCode="403" statusReason="Forbidden" statusDescription="Forbidden" /> 
       </rule> 
       <rule name="ModX IIS7 Rule 2 (By Simon Fraser)" stopProcessing="true"> 
        <match url="^(manager|assets)" ignoreCase="false" /> 
        <action type="None" /> 
       </rule> 
       <rule name="ModX IIS7 Rule 3 (By Simon Fraser)" stopProcessing="true"> 
        <match url="^(.*)$" ignoreCase="false" /> 
        <conditions logicalGrouping="MatchAll"> 
         <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" pattern="" ignoreCase="false" /> 
         <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" pattern="" ignoreCase="false" /> 
        </conditions> 
        <action type="Rewrite" url="index.php?q={R:1}" appendQueryString="true" /> 
       </rule> 
      </rules> 
     </rewrite> 
    </system.webServer> 
</configuration> 
1

あなたのWeb.configファイルを使用して、この内<system.webServer><rewrite>ルールを使用する必要があります。あなたはあなたの.htaccessから上記の持っているコードを複製するために、あなたのweb.config内の以下を使用する必要があります

<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
    <system.webServer> 
     <rewrite> 
      <rules> 
       <rule name="Main Rule" stopProcessing="true"> 
        <match url=".*" /> 
        <conditions logicalGrouping="MatchAll"> 
         <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> 
         <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> 
        </conditions> 
        <action type="Rewrite" url="index.php" /> 
       </rule> 
      </rules> 
     </rewrite> 
    </system.webServer> 
</configuration>