2016-12-02 5 views
2

IISサーバーで初めてCakePHP3を使用しています。CakePHP3 urlがIISサーバー上で書き換えられ、URLからindex.phpを削除しない

私は.htaccessファイルをwebconfigに翻訳し、プロジェクトディレクトリのルートに置いています。

その後、自分のホームページにアクセスできます。

ホームページ: - コントローラ: - ホームとアクション: - route.phpのインデックス: -

$routes->connect('/', ['controller' => 'Home', 'action' => 'index', 'index']);

しかし、私は他のコントローラのアクションにアクセスしようとすると、問題が来ているexample(/cakephp/dashboard/profile): -

Dashboardコントローラのプロファイルアクションにアクセスしようとすると、404が見つかりませんでした。同じコードが.htaccessを使ってLinux上で正しく動作しています。

controller(/cakephp/index.php/dashboard/profile)の後に手動でindex.phpを追加すると問題なく動作します。

誰でも私がこの問題を解決する方法を教えてください。ここで

は、プロジェクトディレクトリである: - このアンダー/をhttpdocs/cakephpの/ 私としてのweb.configファイルを作成している: - ここに

<?xml version="1.0" encoding="UTF-8"?> 
<configuration> 
    <system.webServer> 
      <rewrite> 
       <rules> 
        <clear/> 
       <rule name="Exclude direct access to webroot/*" stopProcessing="true"> 
        <match url="^webroot/(.*)$" ignoreCase="false" /> 
        <action type="None" /> 
       </rule> 
       <rule name="Rewrite routed access to assets(img, css, files, js, favicon)" stopProcessing="true"> 
        <match url="^(img|css|files|js|favicon.ico)(.*)$" /> 
        <action type="Rewrite" url="webroot/{R:1}{R:2}" appendQueryString="false" /> 
       </rule> 

       <rule name="Imported Rule 1" stopProcessing="true"> 
        <match url="^$" ignoreCase="false" /> 
        <action type="Rewrite" url="webroot/" /> 
       </rule> 
       <rule name="Imported Rule 2" stopProcessing="true"> 
        <match url="(.*)" ignoreCase="false" /> 
        <action type="Rewrite" url="webroot/{R:1}" /> 
       </rule> 

        <rule name="Imported Rule 3" stopProcessing="true"> 
         <match url="^" ignoreCase="false" /> 
         <conditions> 
         <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" /> 
         </conditions> 
         <action type="Rewrite" url="index.php" /> 
       </rule> 
       </rules> 
      </rewrite> 
    </system.webServer> 
</configuration> 
+0

こんにちは、Shawaz、私もこの問題を抱えていますか、それとも誰か他の人が考えていますか? – xialin

答えて

0

プロジェクトディレクトリである: - /をhttpdocs/cakephp /これで私はweb.configファイルを作成しました

iisは実際にはディレクトリではなくwebrootディレクトリを指すように設定する必要がありますその上に。 web.configは次のようになります。

<?xml version="1.0" encoding="UTF-8"?> 
<configuration> 
    <system.webServer> 
      <rewrite> 
       <rules> 
        <clear/> 
       <!--- Irrelevant, because webroot/webroot/ doesn't exist 
       <rule name="Exclude direct access to webroot/*" stopProcessing="true"> 
        <match url="^webroot/(.*)$" ignoreCase="false" /> 
        <action type="None" /> 
       </rule> 
       ---> 
       <!--- Unnecessary, because asset urls directly match asset file paths 
       <rule name="Rewrite routed access to assets(img, css, files, js, favicon)" stopProcessing="true"> 
        <match url="^(img|css|files|js|favicon.ico)(.*)$" /> 
        <action type="Rewrite" url="webroot/{R:1}{R:2}" appendQueryString="false" /> 
       </rule> 
       ---> 
       <!--- No exceptions necessary 
       <rule name="Imported Rule 1" stopProcessing="true"> 
        <match url="^$" ignoreCase="false" /> 
        <action type="Rewrite" url="webroot/" /> 
       </rule> 
       <rule name="Imported Rule 2" stopProcessing="true"> 
        <match url="(.*)" ignoreCase="false" /> 
        <action type="Rewrite" url="webroot/{R:1}" /> 
       </rule> 
       ---> 

        <rule name="Imported Rule 3" stopProcessing="true"> 
         <match url="^" ignoreCase="false" /> 
         <conditions> 
         <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" /> 
         </conditions> 
         <action type="Rewrite" url="index.php" /> 
       </rule> 
       </rules> 
      </rewrite> 
    </system.webServer> 
</configuration> 
関連する問題