7

PHP、MySQL、およびApacheを使用してローカルでアプリケーションを開発しました。これには、これを含む.htaccessファイルがあります。

#Setting the default handler.
  DirectoryIndex home.do

<IfModule mod_mime.c>
  #Supporting .do extensions    
     AddType application/x-httpd-php .do
</IfModule>

<IfModule mod_rewrite.c>
  #Removing .do file extension if necessary
     RewriteEngine on
     RewriteCond %{REQUEST_FILENAME} !-d
     RewriteCond %{REQUEST_FILENAME}\.do -f
     RewriteRule ^(.*)$ $1.do
</IfModule>

しかし、顧客の Web サーバーは IIS であり、.htaccess の代わりに web.config ファイルを使用する必要があることを伝えました。誰でも私にこれを案内してもらえますか?

4

3 に答える 3

4

これは不正行為と見なされる可能性がありますが、 ISAPI_Rewriteを使用しているため、IIS の .htaccess ファイルをそのまま使用できます。それらをサーバーに置くことができれば、何も翻訳する必要はありません。

于 2009-04-16T14:41:13.997 に答える
3

これは IIS7 でのみ機能し、IIS6 では機能しないことに注意してください。また、FastCGI をセットアップ、URL 書き換えモジュールをインストールして有効にする必要があります。これらは、ホスティング会社が確認できるものです。上記のすべてが当てはまる場合は、次のファイルでうまくいくはずです (パスを微調整する必要があるかもしれませんが、このサンプル ファイルを提供すれば、ホストはこれを行うことができると思います。

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <configSections>
        <sectionGroup name="system.webServer">
            <sectionGroup name="rewrite">
                <section name="rewriteMaps" overrideModeDefault="Allow" />
                <section name="rules" overrideModeDefault="Allow" />
        </sectionGroup>
    </sectionGroup>
</configSections>

<system.webServer>
    <!-- Mapping the .do extension to the PHP ISAPI module -->
    <handlers>
        <!-- the following line is very specific to your host
             please check the module name and the scriptProcessor 
             path with the system administrator! basically this is 
             the same as
             http://learn.iis.net/page.aspx/246/using-fastcgi-to-host-php-applications-on-iis-70/#EnableFastCGI
             only in .config format. -->
        <add name="MaskDoAsPHP" path=".do" verb="GET,HEAD,POST,DEBUG" modules="FastCgiModule" scriptProcessor="C:\PHP\php-cgi.exe" />
    </handlers>

    <!-- Setting the default handler. -->
    <defaultDocument>
        <files>
            <clear />
            <add value="home.do" />
        </files>
    </defaultDocument>

    <rewrite>
        <rules>
            <rule name="Removing do extension" stopProcessing="true">
                <match url="^(.*)$" ignoreCase="false" />
                <conditions>
                    <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
                </conditions>
                <action type="Rewrite" url="{R1}.do" appendQueryString="true" />
            </rule>
        </rules>
    </rewrite>
</system.webServer>

于 2009-04-14T01:59:39.017 に答える
2

IIS7以降では、 URL書き換えモジュールを使用してApache.htaccessルールをインポートできます。

  1. MicrosoftWebPlatformインストーラーを介してURL書き換えモジュールをインストールします
  2. IISマネージャーを起動し、左側の[接続]ウィンドウで、必要なサイト(デフォルトのWebサイトなど)を選択します。
  3. 中央(機能ビュー)で、[ URL書き換え]をダブルクリックします。
  4. 右側のパネルで[ルールのインポート... ]をクリックし、ルールを.htaccessファイルから[ルールの書き換え]ボックスに貼り付けます
  5. 右側の列で[適用]をクリックします。
于 2012-09-28T08:38:31.093 に答える