我正在使用IIS-7,并且正在将一个站点从基于linux和apache的服务器环境迁移过来。我知道web.config和.htaccess做同样的工作。我希望将.htaccess文件中的以下代码行转换为web.config文件。我该从哪里开始呢?
Options +FollowSymlinks
RewriteEngine On
RewriteRule ([A-Za-z0-9/_-]+).(jp(e?)g|gif|png)$ thumb.php?src=../../uploads/default/files/$1.$2&size=160x90发布于 2014-11-05 04:15:15
要将规则从.htaccess转换为web.config,可以使用IIS重写模块的导入功能
有关此功能的More info。
例如,您的规则被转换为以下规则:
<rewrite>
<rules>
<rule name="Imported Rule 1">
<match url="([A-Za-z0-9/_-]+).(jp(e?)g|gif|png)$" ignoreCase="false" />
<action type="Rewrite" url="thumb.php?src=../../uploads/default/files/{R:1}.{R:2}&size=160x90" appendQueryString="false" />
</rule>
</rules>
</rewrite>发布于 2022-02-19 14:32:52
只需在记事本上创建一个web.config文件,或编辑根文件夹中的文件,然后复制并粘贴以下内容:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Remove index.php rule" stopProcessing="true">
<match url=".*" ignoreCase="false"/>
<conditions>
<add input="{URL}" pattern="^/(media|skin|js)/" ignoreCase="false" 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" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>https://stackoverflow.com/questions/25365508
复制相似问题