[英]Convert .htaccess to web.config
我正在使用 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
要将规则从.htaccess转换为web.config,您可以使用IIS URL重写模块的导入功能:
有关此功能的更多信息 。
例如,您的规则将转换为以下规则:
<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>
只需在记事本上创建 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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.