2014-08-31 58 views
1

我在IIS7服務器上運行Joomla 2.5。IIS不編碼UTF-8網址?

問題是Joomla的搜索引擎友好的網址不工作。無論我輸入什麼網址,都會轉到index.php。

與重寫規則和IIS設置掙扎的痛苦的日子後,我來到了兩種實現:當URL是Unicode的

  1. 搜索引擎友好的網址只破。

  2. 在我的WAMP的服務器,在其上海基會網址完美地工作:

    $_SERVER['REQUEST_URI']"mydomain/%D9%85%D8%AD%D8%B5%D9%88%D9%84%D8%A7%D8%AA/%D9%82%D9%84%D8%A8%DB%8C-%D8%B9%D8%B1%D9%88%D9%82%DB%8C"

    但在IIS

    $_SERVER['REQUEST_URI']"mydomain/???????/????-?????"

它看起來像網址不是URLEncoded。

  • 我已啓用unicode別名,搜索引擎友好的網址,並在Joomla的全局配置中重寫。

  • 我有複製/粘貼web.config.txt到我的web.config。

這裏是我的web.config文件:

<?xml version="1.0" encoding="UTF-8"?> 
<configuration> 
    <appSettings /> 
    <connectionStrings> 
    **** 
    </connectionStrings> 
    <system.web> 
    <compilation debug="true" targetFramework="4.0"> 
     <assemblies> 
    <add assembly="System.Web.Extensions.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=****" /> 
    <add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=****" /> 
    <add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=****" /> 
     </assemblies> 
    </compilation> 
    <customErrors mode="Off" /> 
    <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID" /> 
    </system.web> 
    <system.webServer> 
     <directoryBrowse enabled="false" /> 
     <defaultDocument> 
      <files> 
       <clear /> 
       <add value="Default.htm" /> 
       <add value="default.html" /> 
       <add value="Default.asp" /> 
       <add value="default.aspx" /> 
       <add value="default.php" /> 
       <add value="default.pl" /> 
       <add value="default.cgi" /> 
       <add value="index.htm" /> 
       <add value="index.html" /> 
       <add value="index.asp" /> 
       <add value="index.aspx" /> 
       <add value="index.php" /> 
       <add value="index.pl" /> 
       <add value="index.cgi" /> 
       <add value="iisstart.htm" /> 
       <add value="_holding.html" /> 
      </files> 
     </defaultDocument> 
     <security> 
      <requestFiltering> 
       <hiddenSegments> 
        <add segment="backup" /> 
        <add segment="oldsite" /> 
        <add segment="logs" /> 
        <add segment="tmp" /> 
        <add segment="upload" /> 
       </hiddenSegments> 
      </requestFiltering> 
     </security> 
     <httpErrors> 
      <remove statusCode="404" subStatusCode="-1" /> 
      <error statusCode="404" prefixLanguageFilePath="" path="/" responseMode="ExecuteURL" /> 
     </httpErrors> 
     <rewrite> 
      <rules> 
       <clear /> 
       <rule name="Common Exploit Blocking" stopProcessing="true"> 
        <match url="^(.*)$" /> 
        <conditions logicalGrouping="MatchAny"> 
         <add input="{QUERY_STRING}" pattern="mosConfig_[a-zA-Z_]{1,21}(=|\%3D)" /> 
         <add input="{QUERY_STRING}" pattern="base64_encode.*\(.*\)" /> 
         <add input="{QUERY_STRING}" pattern="(\&lt;|%3C).*script.*(\>|%3E)" /> 
         <add input="{QUERY_STRING}" pattern="GLOBALS(=|\[|\%[0-9A-Z]{0,2})" /> 
         <add input="{QUERY_STRING}" pattern="_REQUEST(=|\[|\%[0-9A-Z]{0,2})" /> 
        </conditions> 
        <action type="Redirect" url="index.php" appendQueryString="false" redirectType="SeeOther" /> 
       </rule> 
       <rule name="Joomla Search Rule" stopProcessing="true"> 
        <match url="(.*)" ignoreCase="true" /> 
        <conditions logicalGrouping="MatchAll"> 
         <add input="{URL}" pattern="^/search.php" ignoreCase="true" /> 
        </conditions> 
        <action type="Rewrite" url="/index.php?option=com_content&amp;view=article&amp;id=4" /> 
       </rule> 
       <rule name="Joomla Main Rewrite Rule" stopProcessing="true"> 
        <match url="(.*)" ignoreCase="true" /> 
        <conditions logicalGrouping="MatchAll"> 
         <add input="{URL}" pattern="(/[^.]*|\.(php|html?|feed|pdf|raw))$" /> 
         <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> 
         <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> 
        </conditions> 
        <action type="Rewrite" url="index.php/" /> 
       </rule> 
      </rules> 
     </rewrite> 
     <caching> 
      <profiles> 
       <add extension=".php" policy="DisableCache" kernelCachePolicy="DisableCache" /> 
      </profiles> 
     </caching> 
    </system.webServer> 
</configuration> 

回答

4

這是IIS7的一個已知的bug,有一個修復它,但我在託管環境中沒有安裝修補程序的權限。下面就來詳細的解釋了微軟支持網站,併爲問題的決議鏈接:FIX: A PHP application that depends on the REQUEST_URI server variable may fail when a request whose URL contains UTF-8 characters is sent to IIS 7.5

但是如果你無法安裝修補程序,這裏有一個解決方法,以獲取Joomla的SEF的網址使用Unicode工作:

的文檔說php的$_SERVER['REQUEST_URI']不能用於unicode url重寫,但我發現參數的工作很完美。我們可以把URL作爲參數傳遞給PHP代碼並將其指定爲$_SERVER['REQUEST_URI']

  1. 更改你的第二個重寫規則在web.config文件如下:

    <rule name="Joomla! Rule 2"> 
        <match url="(.*)" ignoreCase="false" /> 
        <conditions logicalGrouping="MatchAll" trackAllCaptures="false"> 
         <add input="{URL}" pattern="^/index.php" negate="true" /> 
         <add input="{URL}" pattern="/component/|(/[^.]*|\.(php|html?|feed|pdf|vcf|raw))$" /> 
         <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> 
         <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> 
        </conditions> 
        <action type="Rewrite" url="index.php?requesturi={URL}" /> 
    </rule> 
    

    唯一的變化是修改在<action>標籤

  2. 在你的index.php(位於你的Joomla站點的根目錄)url屬性,在頂部(只是<?php開始標記之後)添加此

    $_SERVER['REQUEST_URI'] = $_GET['requesturi']; 
    

完成。你的美化網址中有unicode。

+1

男人你是天才,謝謝你。 – 2016-03-03 13:43:35

+0

非常感謝,你救了我的一天。我將我的WordPress從Linux託管移到Windows,並面臨這個問題。您的解決方案也適用於Wordpress(https://wordpress.stackexchange.com/questions/94882) – 2017-07-09 19:36:53