2017-07-06 92 views
0

我有以下.htaccess文件:的RewriteCond無法找到文件中它

<IfModule mod_rewrite.c> 
    Options +FollowSymlinks 
    RewriteEngine On 
    RewriteBase/

    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule ^.*$ index.php [L] 
</IfModule> 

它重定向一切的index.php,如果它不是一個文件或目錄。它工作正常,但是當一個文件的名稱中有一個重音時,它會將url重定向到index.php,因此RewriteCond無法檢測到它是現有文件。例如(有兩個文件):

此作品:http://example.com/something.pdf(給我的PDF)

但這並不:http://example.com/somethingá.pdf(我重定向到index.php)

的問題是,我無法訪問Web服務器conf,因爲它位於虛擬主機服務器上。

的系統爲Windows Server 2008 R2的Web服務器版Service Pack 1(PHPINFO)

Web服務器:微軟IIS/7.5

+1

Apache版本?在Win7開發框中使用XAMMP(Apache 2.4.3)可以正常工作。 – CD001

+0

@ CD001編輯我的帖子,但它是Microsoft-IIS/7.5。 – Fenistil

+1

這就是你的問題他們,'.htaccess','mod_rewrite'等都是Apache特定的 - IIS使用* Web.config * XML文件,我相信。 – CD001

回答

0

基於CD001的評論中,我發現,但是IIS可以自動轉換.htacess文件,但不能一直運行100%。所以我通過手動將.htaccess文件轉換爲web.config文件修復了這個問題。轉換後的文件是:

<?xml version="1.0" encoding="UTF-8"?> 
<configuration> 
    <system.webServer> 
     <rewrite> 
      <rules> 
       <rule name="Rule 1"> 
        <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="index.php" /> 
       </rule> 
      </rules> 
     </rewrite> 
    </system.webServer> 
</configuration> 

保存在你的網頁的根得到它的工作,並刪除.htacessweb.config