【发布时间】:2013-12-17 21:10:21
【问题描述】:
您好:我需要帮助将我的 IIS 重写规则转换为 .htaccess 文件。 我对服务器规则不是很有经验(我主要设计和开发网站)。 我需要一些帮助。我目前正在将一个网站 (dolyn.com) 从另一台服务器转移到我们的网站,他们最初使用 WIMP 设置启动它,因此使用来自 IIS (web.config) 的 URL 重写而不是来自 Apache (.htacces) 的 mod_rewrite 模块 [我真的不太了解它的后勤工作 - 我刚刚被要求确保它在我们的服务器上工作。这是原始的 web.config 文件:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<!-- Doesn't work on DEV servers, uncomment it on live site -->
<!-- httpErrors errorMode="Detailed" /-->
<rewrite>
<rules>
<clear />
<!--
This rule will redirect all requests to a single main domain as specified in the 1st condition, except if it's on a baytek dev site.
Instructions:
1. Enable the rule
2. Change "^www.maindomain.com$" to real domain, ex. "^www.bayteksystems.com$", in both places.
-->
<rule name="Redirect to WWW" stopProcessing="true" enabled="false">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTP_HOST}" pattern="^www.maindomain.com$" negate="true" />
<add input="{HTTP_HOST}" pattern="dev.bayteksystems.com$" negate="true" />
</conditions>
<action type="Redirect" url="http://www.maindomain.com/{ToLower:{R:0}}" redirectType="Permanent" />
</rule>
<rule name="Add trailing slash" stopProcessing="true">
<match url="(.*[^/])$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Redirect" url="{ToLower:{R:1}}/" redirectType="Permanent" />
</rule>
<rule name="Convert to lower case" stopProcessing="true">
<match url=".*[A-Z].*" ignoreCase="false" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Redirect" url="{ToLower:{R:0}}" redirectType="Permanent" />
</rule>
<rule name="DynamicURLs" enabled="true" stopProcessing="true">
<match url="^(.*)$" />
<conditions logicalGrouping="MatchAll">
<add input="{URL}" pattern="^_cms.*" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="index.php?page={R:1}&url_rewrite=true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
我已经做了很多研究,看起来我可能还需要一个 .htpasswd 文件?它是否正确?正如您可以从 web.config 中看到的那样,它来自baytechsystems.com 的服务器,我们正在将其移至dnsnetworks.ca
【问题讨论】:
标签: apache .htaccess iis mod-rewrite web-config