【发布时间】:2016-02-17 12:03:55
【问题描述】:
我的域 xyz.com 托管在 Windows 服务器上。
xyz.com 的代码是用 PHP 编写的(以前是用 ASP.NET 编写的)。数据库是 MySQL(以前是在 SQL server 中)。
现在用 PHP 重新开发整个网站后,我知道.htaccess 无法在 Windows 服务器上运行。我必须和web.config一起玩。
这是我在本地用 PHP 重新开发网站时使用的 .htaccess 代码:
RewriteRule index.html index.php
RewriteRule news.html news.php
RewriteRule search-results.html search-results.php
RewriteRule ^([A-Za-z0-9_\-]+).html$ pages.php?pageid=$1&%{QUERY_STRING} [ne]
发生了一件奇怪的事情
当我在 web.config 中添加以下代码行时,它运行良好
<rules>
<clear />
<rule name="Redirect to google.com" stopProcessing="true">
<match url="^google$" />
<action type="Redirect" url="http://www.google.com/" appendQueryString="false" />
</rule>
</rules>
上面的代码将我重定向到google.com,这意味着重写模块已经启用
但是当我将下面提到的代码添加到 web.config 时
<rules>
<rule name="REWRITE_TO_PHP">
<match url="^(.+).html$" />
<conditions logicalGrouping="MatchAll" />
<action type="Rewrite" url="pages.php?pageid={R:1}" />
</rule>
它给了我错误:
HTTP 错误 500.19 - 内部服务器错误 请求的页面无法访问,因为该页面的相关配置数据无效。
谁能帮我创建等效的web.config 代码?
【问题讨论】:
-
谁能帮忙?从 8 小时开始我就陷入了这些困境!
标签: php .htaccess web-config windows-server-2008