将 .htaccess 转换为 web.config [英] Convert .htaccess to web.config

查看:35
本文介绍了将 .htaccess 转换为 web.config的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 IIS-7,并且正在从基于 linux 和 apache 的服务器环境中移动站点.我知道 web.config 与 .htaccess 做同样的工作.我希望将以下几行从我的 .htaccess 文件转换为 web.config 文件.我该从哪里开始?

I'm using IIS-7 and am moving a site over from a linux and apache based server environment. I know web.config does the same job as .htaccess. I'm looking to convert the following lines from my .htaccess file to a web.config file. Where would I begin?

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 重写模块的导入功能:

To convert rules from .htaccess to web.config you can use import feature of the IIS URL Rewrite Module:

  1. 转到IIS 管理器
  2. 在树中点击您的站点
  3. 在功能视图中双击URL Rewrite
  4. 点击操作面板中的导入规则
  5. 将您的 .htaccess 规则粘贴到重写规则文本框中,您将在下方看到转换后的规则.
  1. go to IIS Manager
  2. click you site in the tree
  3. double-click URL Rewrite in the Feature View
  4. click Import Rules in the Actions panel
  5. paste your .htaccess rules into the Rewrite rules textbox and you'd see your converted rules below.

更多信息功能.

例如,您的规则将转换为以下规则:

For instance your rules are converted into these ones:

<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}&amp;size=160x90" appendQueryString="false" />
    </rule>
  </rules>
</rewrite>

这篇关于将 .htaccess 转换为 web.config的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆