gpt4 book ai didi

iis - IIS7 上的 Joomla 搜索引擎友好 URL 问题

转载 作者:塔克拉玛干 更新时间:2023-11-03 02:29:14 24 4
gpt4 key购买 nike

我有 Joomla 1.5.9 运行 php 5.2.8,mySQL 5.1.31 在 IIS7 上的 vista 64 开发框。我的 SEO 设置“搜索引擎友好 URL”和“使用 Apache mod_rewrite”都正常工作。

我也在建立一个托管站点(使用 www.mochahosting.com)。他们使用相同软件的稍旧版本:Joomla 1.5.5、php 5.2.6、mySQL 5.0.4x。他们也使用 IIS7,但在 Windows 32 上运行。

我无法在托管站点 上使用 的任何 SEO 设置(我已将 SEO 设置用于我的本地机器,配置几乎相同)。让我们从“搜索引擎友好的 URL”开始,只是为了让事情变得简单。

另外,我还没有域名,所以我使用主机文件别名来访问该站点。我不指望有人会遇到这样的麻烦来回答我的问题,所以我只会描述这个问题,并希望我做得足够好,让人们能够理解正在发生的事情。出于此问题的目的,我将使用 http://nodomainyet.com/joomla156_mx 作为基本 URL(即 joomla 主页)。是的,这确实意味着 Joomla 安装在一个子目录中——我不确定这是否有问题(这不是我的开发箱上的问题)。

到问题。

打开“搜索引擎友好 URL”会导致 http://nodomainyet.com/joomla156_mx 生成 404(“找不到组件”)。在 404 错误页面中,有一个指向 http://nodomainyet.com/joomla156_mx/index.php 的链接——该链接有效。如果我关闭“搜索引擎友好 URL”,那么 http://nodomainyet.com/joomla156_mxhttp://nodomainyet.com/joomla156_mx/index.php 都可以工作。因此,似乎打开“搜索引擎友好的 URL”会导致 http://nodomainyet.com/joomla156_mx 的“自动重定向”到 http://nodomainyet.com/joomla156_mx/index.php 停止工作......

现在,如果我转到 http://nodomainyet.com/joomla156_mx/index.php 并从那里导航到各种主菜单链接(我只使用安装了新 Joomla 实例的默认 joomla 站点),那么一切正常。它只是去 http://nodomainyet.com/joomla156_mx 不起作用。值得注意的是,主菜单中的“主页”链接默认转到 http://nodomainyet.com/joomla156_mx

我已经将主机上 phpinfo 的输出与我的开发箱的输出进行了比较,但看不到任何会导致此问题的差异...

打开第二个 SEO 设置——“使用 Apache mod_rewrite”——并没有解决问题(有人会认为它可以,因为该设置的目的是摆脱 URL 中的 index.php)。

“搜索引擎友好的 URL”通常看起来很容易开始工作——它不需要 web.config 和重写规则......我不确定是什么可能导致它出错。

更新 - 2009-03-03

我认为仅从 ("Use Apache mod_rewrite") 打开第一个 SEO 设置("搜索引擎友好的 URL")可能是一个坏主意(即使我可以在我的计算机上单独打开"搜索引擎友好的 URL")本地机器,它工作正常)。所以我尝试了更多的实验

我认为问题可能在于主机上的 IIS7 中未正确设置 URL 重写。我做了在 http://learn.iis.net/page.aspx/461/creating-rewrite-rules-for-the-url-rewrite-module 中描述的(第一个)测试文件并且它起作用了——所以这意味着 URL 重写正在起作用。

然后我想也许问题在于,在IIS7上到处看到的Joomla的重写规则需要重写以考虑子目录。就像我上面说的,SEO 设置在我的本地机器上运行良好。 Joomla 也安装在一个子目录中,一切正常。尽管如此,我还是尝试修改重写规则

<rewrite>
<rules>
<rule name="Imported Rule 1" enabled="true">
<match url="(.*)" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" pattern="" ignoreCase="false" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" pattern="" ignoreCase="false" />
<add input="{SCRIPT_NAME}" negate="true" pattern="^/index.php" ignoreCase="false" />
<add input="{SCRIPT_NAME}" pattern="(/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$" />
</conditions>
<action type="Rewrite" url="index.php" />
</rule>
</rules>
</rewrite>


<rewrite>
<rules>
<rule name="Imported Rule 1" enabled="true">
<match url="(.*)" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" pattern="" ignoreCase="false" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" pattern="" ignoreCase="false" />
<add input="{SCRIPT_NAME}" negate="true" pattern="^/joomla156mx/index.php" ignoreCase="false" />
<add input="{SCRIPT_NAME}" pattern="(/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$" />
</conditions>
<action type="Rewrite" url="joomla156mx/index.php" />
</rule>
</rules>
</rewrite>

(即,在条件和操作之前添加目录名称)。那没有任何区别。现在,我对重写规则完全陌生,所以我可能搞砸了一些事情。

我想我觉得没有重定向规则有点可疑;意思是如果我复制并粘贴一个“重写”的 URL,是否不需要告诉服务器这是一个虚构的 URL,它应该被重定向到一个真实的 URL?但是,同样,这在我的本地盒子上运行良好,具有简单的旧重写规则,所以我可能在错误的树上吠叫。

谢谢您的帮助!

最佳答案

此页面上的最后一步遍历 Enabling Search Engine Friendly URLs

By default Joomla uses query string parameters for all the links URLs it generates for your web site. This behavior can be changed by enabling what is called "Search Engine Friendly URLs" in Joomla. However, this feature relies on the URL rewriting functionality to be available on the web server. IIS 6.0 does not have URL rewriting capabilities, so you could use one of the third party URL rewriting products, such as ISAPI_Rewrite or Ionics ISAPI Rewrite Filter. IIS 7.0 has URL rewriting support, which can be enabled by installing Microsoft URL Rewrite Module for IIS 7.0. The following instructions describe how URL Rewrite Module for IIS 7.0 can be used to enable Clean URLs in Joomla.
First, you will need to download and install Microsoft URL Rewrite Module. Once it has been installed, create and open a web.config file located in C:\inetpub\wwwroot\Joomla folder. Paste the following XML code into this file.


<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Security Rule" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions logicalGrouping="MatchAny">
<add input="{QUERY_STRING}" pattern="mosConfig_[a-zA-Z_]{1,21}(=|\%3D)" ignoreCase="false" />
<add input="{QUERY_STRING}" pattern="base64_encode.*\(.*\)" ignoreCase="false" />
<add input="{QUERY_STRING}" pattern="(\&lt;|%3C).*script.*(\>|%3E)" />
<add input="{QUERY_STRING}" pattern="GLOBALS(=|\[|\%[0-9A-Z]{0,2})" ignoreCase="false" />
<add input="{QUERY_STRING}" pattern="_REQUEST(=|\[|\%[0-9A-Z]{0,2})" ignoreCase="false" />
</conditions>
<action type="CustomResponse" url="index.php" statusCode="403" statusReason="Forbidden" statusDescription="Forbidden" />
</rule>
<rule name="SEO Rule">
<match url="(.*)" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" pattern="" ignoreCase="false" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" pattern="" ignoreCase="false" />
<add input="{URL}" negate="true" pattern="^/index.php" ignoreCase="false" />
<add input="{URL}" pattern="(/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$" />
</conditions>
<action type="Rewrite" url="index.php" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>

保存 web.config 文件,然后打开 Web 浏览器并通过 http://localhost/joomla/administrator/ 登录到 Joomla 管理员控制台。登录后,转到站点 --> 全局配置菜单配置 SEO 设置如下:
  • 搜索引擎友好 URL - 是
  • 使用 Apache mod_rewrite - 是
  • 为 URL 添加后缀 - 无
  • 单击“应用”保存配置,然后浏览至 http://localhost/joomla/ 。您将看到现在 Joomla 页面中的所有链接都具有没有查询字符串参数的 URL,如果您单击这些链接中的任何一个,服务器将返回正确的响应:

    关于iis - IIS7 上的 Joomla 搜索引擎友好 URL 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/599184/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com