我如何使用xml隐藏web.config中的页面名称?

问题描述 投票:0回答:1

我想知道是否有一种方法可以隐藏网站上的页面名称(在浏览器URL中),但仍使用IIS web.config文件显示get请求?

想象站点名称是www.website.com

带有页面的(文件扩展名已被隐藏)www.website.com/page.php

www.website.com/page.php?user=text其中“文本”是动态的

并且我希望它显示为www.website.com/text

这有可能吗?

我注意到一个类似的问题here,但是即使将asp更改为XML,该方法似乎也不起作用。

提前感谢!

编辑:这是我尝试使用的xml代码(此特定代码无效)

<rule name="subFolderValueRedirect" enabled="true">
<conditions>
<add input="{REQUEST_URI}" pattern="^/page\.php?user=([^/]+)$" />
</conditions>
<action type="Redirect" url="/{C:2}" />
</rule>
<rule name="fileValueRewrite" enabled="true">
<conditions>
<add input="{REQUEST_URI}" pattern="^/([^/]+)/([a-zA-Z0-9]+)$" /></conditions>
<action type="Rewrite" url="/page.php?user={C:2}" />
</rule>
php xml iis server web-config
1个回答
0
投票

根据您的描述,建议您尝试使用以下URL重写规则。

您可以首先将URL从www.website.com/page.php?user=text重定向到www.website.com/text,然后可以将www.website.com/text重写为/page.php?user=text

规则如下:

            <rule name="Re1" stopProcessing="true">
                <match url="page.php" />
                <conditions>
                    <add input="{QUERY_STRING}" pattern="user=([^/]+)$" />
                </conditions>
                <action type="Redirect" url="http://localhost:9082/text" appendQueryString="false" />
            </rule>
            <rule name="RE2">
                <match url="([a-zA-Z0-9]+)$" />
                <action type="Rewrite" url="/page.php?user={R:0}" appendQueryString="false" />
            </rule>
© www.soinside.com 2019 - 2024. All rights reserved.