【问题标题】:I want to convert .htaccess file to web.config [closed]我想将 .htaccess 文件转换为 web.config [关闭]
【发布时间】:2012-07-25 10:33:15
【问题描述】:

我想将.htaccess 文件转换为web.config

这里是代码

AddType application/x-httpd-php .html
RewriteEngine on

RewriteBase /

RewriteCond %{Request_Filename} !-d
RewriteCond %{Request_Filenam}e !-f

RewriteRule ^pages/([0-9A-Za-z_\-~',]+) page_details.html?category_page_title=$1 [NC]

谁能帮我把这个 .htaccess 文件转换成 web.config 文件。

提前致谢。

【问题讨论】:

  • 如果您尝试过这一点,哪怕只是一点点,那就太好了。我们在这里非常尊重努力,即使它是错误的或被误导的。即使对IIS UrlRewrite 文档进行最简短的扫描,您也会看到此链接:learn.iis.net/page.aspx/470/importing-apache-modrewrite-rules,或者可能通过单击 IIS UrlRewrite 功能 RHS 操作面板中的帮助按钮。即使导入不能正常工作,我们也非常欢迎帮助解决这个问题,因为现在我们有一些工作要做。谢谢。

标签: php .htaccess iis web-config


【解决方案1】:

关于整个.htaccess文件的转换,请参见本手册:http://learn.iis.net/page.aspx/557/translate-htaccess-content-to-iis-webconfig/

非常全面,解释了如何转换规则。


如果您只想重写规则转换,请阅读这篇文章: http://learn.iis.net/page.aspx/470/importing-apache-modrewrite-rules/

这是一个更加循序渐进的 gui 指南,但在您的情况下,它可能就足够了。


无论如何,您列出的规则可能会以web.config的(部分)结尾:

    <rewrite>
        <rules>
            <rule name="page details" stopProcessing="true">
                <match url="^/pages/([0-9A-Za-z_\-~',]+)" ignoreCase="true" />
                <conditions>
                    <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
                </conditions>

                <action type="Redirect" redirectType="Permanent" url="/page_details.html?category_page_title={R:1}" />
            </rule>
        </rules>
    </rewrite>

【讨论】:

    猜你喜欢
    • 2017-01-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多