将.htaccess(PHP)行转换为web.config行(IIS)
我在.htaccess文件中有这些行,并已将我的站点移动到IIS环境中。我非常确定它需要进入根目录中的web.config文件,但我完全迷路了,尝试了所有方法都没有成功。这样做的目的是将带有.php、.htm或.html的任何内容定向到根目录中的index.php页面,这样我就可以控制显示的内容并使其模块化。它将在查询字符串中附加文件名,以便我可以从那里引导内容。不管怎样,这就是我要做的。htaccess:将.htaccess(PHP)行转换为web.config行(IIS),.htaccess,web-config,rewrite,iis-7.5,.htaccess,Web Config,Rewrite,Iis 7.5,我在.htaccess文件中有这些行,并已将我的站点移动到IIS环境中。我非常确定它需要进入根目录中的web.config文件,但我完全迷路了,尝试了所有方法都没有成功。这样做的目的是将带有.php、.htm或.html的任何内容定向到根目录中的index.php页面,这样我就可以控制显示的内容并使其模块化。它将在查询字符串中附加文件名,以便我可以从那里引导内容。不管怎样,这就是我要做的。htaccess: RewriteCond %{REQUEST_FILENAME} (\.php|.htm|
RewriteCond %{REQUEST_FILENAME} (\.php|.htm|.html)$
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
您可以使用此Microsoft支持的配置导入
mod_rewrite rules
并将其转换为IIS URL rewrite rules
web.config
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Rule 1" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" pattern="\.(php|htm|html)$" ignoreCase="false" />
</conditions>
<action type="Rewrite" url="index.php?q={R:1}" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
非常感谢您为我指明url重写模块的方向。我已经尝试过使用它,但不知道它有导入功能!!在我导入.htaccess行之后,它仍然不起作用(正如导入lol所预期的那样),但是在我稍微调整reqex之后,所有的都起作用了!!!再次感谢你帮助我。对于任何想要正确的web.config设置的人,这里是:)
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Imported Rule 1" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="Pattern" pattern="(.*php|.*htm|.*html)$" ignoreCase="true" negate="false" />
</conditions>
<action type="Rewrite" url="index.php?q={R:1}" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>