将URL重写重定向规则转换为htaccess

时间:2015-11-17 22:29:41

标签: apache .htaccess mod-rewrite url-rewriting

我有一个使用handlebar.js模板的静态SPA网站。它适用于IIS,具有以下URL重写规则,但我需要将其移动到使用.htaccess的服务器。我不确定如何将以下网址重写规则转换为.htaccess重写规则:

<system.webServer>
    <rewrite>
        <rules>
            <rule name="RewriteUserFriendlyURL1" stopProcessing="true">
                <match url="^([^/]+)/([^/]+).html" />
                <conditions>
                    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                </conditions>
                <action type="Rewrite" url="index.html?category={R:1}&amp;page={R:2}" />
            </rule>
        </rules>
    </rewrite>
</system.webServer>

1 个答案:

答案 0 :(得分:0)

RewriteEngine on
RewriteRule ^([^\/]+)\/([^\/]+)\/?\.html  /index.html?category=$1&page=$2 [L]