2012-09-19 24 views
2

我有問題,嘗試配置的國防部重寫了窗戶和II7: CakePHP 2.2.2 not working on Windows IIS7但最後我能以創建的web.config文件IIS7導入htaccess的。的.htaccess和CakePHP 2在Windows IIS7

的事情是: 現在文件已經在CakePHP的文件夾中創建和我可以訪問到主頁尚未裏面應用程序/創建的應用程序/ webroot的您可以在其中找到另外2個.htaccess文件。

現在,我無法訪問主站點以外的任何其他視圖,它顯示404頁面未找到錯誤,我確信它是因爲它沒有在web.config中獲取這些.htaccess文件。

我的CakePHP 的web.config文件看起來是這樣的:

<?xml version="1.0" encoding="UTF-8"?> 
<configuration> 
<system.webServer> 
    <rewrite> 
     <rules> 
      <rule name="Imported Rule 1" stopProcessing="true"> 
       <match url="^$" ignoreCase="false" /> 
       <action type="Rewrite" url="app/webroot/" /> 
      </rule> 
      <rule name="Imported Rule 2" stopProcessing="true"> 
       <match url="(.*)" ignoreCase="false" /> 
       <action type="Rewrite" url="app/webroot/{R:1}" /> 
      </rule> 
     </rules> 
    </rewrite> 
</system.webServer> 
</configuration> 

雖然CakePHP的文檔告訴你添加不同的代碼(這使得意見工作,但沒有風格被加載並主頁。不工作) http://book.cakephp.org/2.0/en/installation/advanced-installation.html#url-rewrites-on-iis7-windows-hosts

當試圖訪問從URL CSS文件我得到這個消息:

Missing Controller 

Error: CssController could not be found. 

Error: Create the class CssController below in file: app\Controller\CssController.php 

<?php 
class CssController extends AppController { 

} 

有什麼想法?與CakePHP的窗口上的工作讓我發瘋了...

回答

7

我要指出,我的反應是在這裏張貼在解決方案的改進:http://www2.palomar.edu/pages/sphillips/cakephp-with-iis-7-rewrite-rules-in-a-sub-folder/

一種更簡單,更靈活的解決將是擺脫/{Path_To_CakePHP_Directory}/乾脆,包括前進斜槓(/)。通過保持路徑相對,您的項目文件夾變得更加靈活。這是web.config的樣子:

<configuration> 
    <system.webServer> 
    <rewrite> 
     <rules> 
     <clear/> 
     <rule name="Imported Rule 0" stopProcessing="true"> 
      <match url="^(img|css|files|js)(.*)$"></match> 
      <action type="Rewrite" url="app/webroot/{R:1}{R:2}" appendQueryString="false"></action> 
     </rule> 
     <rule name="Imported Rule 1" stopProcessing="true"> 
      <match url="^(.*)$" ignoreCase="false" /> 
      <conditions logicalGrouping="MatchAll"> 
      <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> 
      <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> 
      </conditions> 
      <action type="Rewrite" url="index.php?url={R:1}" appendQueryString="true" /> 
     </rule> 
     <rule name="Imported Rule 2" stopProcessing="true"> 
      <match url="^$" ignoreCase="false" /> 
      <action type="Rewrite" url="app/webroot/" /> 
     </rule> 
     <rule name="Imported Rule 3" stopProcessing="true"> 
      <match url="(.*)" ignoreCase="false" /> 
      <action type="Rewrite" url="app/webroot/{R:1}" /> 
     </rule> 
     <rule name="Imported Rule 4" stopProcessing="true"> 
      <match url="^(.*)$" ignoreCase="false" /> 
      <conditions logicalGrouping="MatchAll"> 
      <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> 
      <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> 
      </conditions> 
      <action type="Rewrite" url="index.php?url={R:1}" appendQueryString="true" /> 
     </rule> 
     </rules> 
    </rewrite> 
    </system.webServer> 
</configuration> 
+0

它工作正常tnak你... –

+0

規則1和規則4應該是完全一樣的嗎? – NikG