我在IIS7服务器上运行Joomla 2.5。
问题是Joomla的搜索引擎友好的网址不起作用。无论我输入什么网址,都会转到index.php。
在经历了重写规则和IIS设置的艰难挣扎之后,我开始实现两个方面:
搜索引擎友好的网址只有在网址为unicode时才会被破坏。
在我的WAMP服务器中,SEF网址完美运行:
$_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="(\<|%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&view=article&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>
答案 0 :(得分:4)
这是IIS7的已知错误,并且有一个修补程序,但我在没有安装修补程序权限的托管环境中。以下是Microsoft支持网站的链接,其中包含详细说明和问题解决方案: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']
更改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>
唯一的变化是修改url
代码的<action>
属性
在index.php(位于Joomla网站的根目录)中,将其添加到顶部(在<?php
开头标记之后)
$_SERVER['REQUEST_URI'] = $_GET['requesturi'];
完成。你的美化网址中有unicode。