2014-03-12 52 views
0

您好我有一個codeigniter網站工作完美的loacl服務器上的wamp,但是當我上傳我的在線服務器上的文件是iis 7.5有主頁工作正常,但是當我打開其他頁面像mysite.com/products它給出了錯誤,但是當我把這個網址這樣的mysite.com/index.php/products然後它工作正常。在上傳文件之前,我刪除了服務器中的一些文件夾iis的一些配置文件夾。我如何創建web.config文件。有配置文件夾的任何層次結構?codeigniter .htaccess不工作在iis 7.5

回答

1

在IIS管理器中使用URL重寫工具來導入刪除url中的index.php的.htaccess文件。這將創建一個IIS web.config文件。你的.htaccess應該是這個樣子:

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase /yourappfolder 

#Removes access to the system folder by users. 
#Additionally this will allow you to create a System.php controller, 
#previously this would not have been possible. 
#‘system’ can be replaced if you have renamed your system folder. 
RewriteCond %{REQUEST_URI} ^system.* 
RewriteRule ^(.*)$ /index.php/$1 [L] 

#Checks to see if the user is attempting to access a valid file, 
#such as an image or css document, if this isn’t true it sends the 
#request to index.php 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
#This last condition enables access to the images and css folders, and the robots.txt file 
RewriteCond $1 !^(index\.php|images|robots\.txt|css) 
RewriteRule ^(.*)$ index.php/$1 [L] 
</IfModule> 

<IfModule !mod_rewrite.c> 
ErrorDocument 404 /index.php 
</IfModule> 

而且你的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" /> 
        <conditions logicalGrouping="MatchAll"> 
         <add input="{URL}" pattern="^system.*" ignoreCase="false" /> 
        </conditions> 
        <action type="Rewrite" url="/index.php/{R:1}" /> 
       </rule> 
       <rule name="Imported Rule 2" stopProcessing="true"> 
        <match url="^(.*)$" ignoreCase="false" /> 
        <conditions logicalGrouping="MatchAll"> 
         <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" /> 
         <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" /> 
         <add input="{R:1}" pattern="^(index\.php|images|robots\.txt|css)" ignoreCase="false" negate="true" /> 
        </conditions> 
        <action type="Rewrite" url="index.php/{R:1}" /> 
       </rule> 
      </rules> 
     </rewrite> 
    </system.webServer> 
</configuration>