将旧的 .htaccess 规则转换为 IIS 重写规则

将旧的 .htaccess 规则转换为 IIS 重写规则

我已经开始在 IIS 上托管我自己的网站,它之前托管在 Apache 上的 DreamHost 上,因此我有一个包含重写规则的 .htaccess 文件,我想将其转换为 URL 重写模块规则。

# initialize mod_rewrite
RewriteEngine on
RewriteBase /

# remove the www from the url
# RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
# RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

###  BEGIN GENERATED REWRITE RULES  ####

RewriteCond %{REQUEST_FILENAME}/index.html -f
RewriteRule ^(.*) $1/index.html

####  END GENERATED REWRITE RULES  ####

# listing pages whose names are the same as their enclosing folder's
RewriteCond %{REQUEST_FILENAME}/$1.html -f
RewriteRule ^([^/]*)/$ %{REQUEST_FILENAME}/$1.html

# regular pages
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^.*$ %{REQUEST_FILENAME}.html

# set our custom 404 page
ErrorDocument 404 /404.html

我正在使用 Hyde 应用程序来生成我的静态网站,所以如果可能的话,我想让它工作。我尝试导入 htaccess,但规则似乎没有给出正确的结果。

答案1

如果你只想将 .htaccess 转储到根文件夹并让 IIS 遵守重写规则,那么有一个名为ISAPI 重写。我们使用付费版本,但如果只有一个网站,免费版本也应该足够了。

IIS7 重写语法(显然)完全不同,而且我不知道是否存在任何工具。

相关内容