【问题标题】:URL rewrite from trailing string to GET variableURL 从尾随字符串重写为 GET 变量
【发布时间】:2020-12-10 03:44:35
【问题描述】:

我已经搜索过这个,但似乎无法找到正确的搜索词 - 这似乎是一个常见问题。

WIMP,IIS 版本为 8

我想提出一个重写规则: 传入网址:http://example.com/1a2b3cdef 改写为:http://example.com?p=1a2b3cdef

注意,这个网址的开头总是“http://example.com/”(不是真正的域名),永远不会改变。

从那里我的 index.php 的默认文档将检索 GET 变量 p。 非常感谢任何帮助。

【问题讨论】:

    标签: url-rewriting iis-8


    【解决方案1】:

    这是可以在 web.config 中应用的配置。

    <defaultDocument>
    
                <files>
    
                    <add value="index.php" />
    
                </files>
    
            </defaultDocument>
    
            <rewrite>
    
                <rules>
    
                    <rule name="rewrite" enabled="true">
    
                        <match url="^[_0-9a-z]+" />
    
                        <action type="Rewrite" url="?p={R:0}" />
    
                    </rule>
    
                </rules>
    
            </rewrite>
    

    【讨论】:

    • 谢谢乔基斯。我很感激你在这里的时间。看起来很简单,但我正在尝试的在 IIS 中对我不起作用。你的完美!
    • @约翰。我很高兴该规则可以解决您的问题。如果您能接受它作为答案,我们将不胜感激,以便该规则可以帮助其他人。
    猜你喜欢
    • 2011-04-02
    • 2011-03-09
    • 1970-01-01
    • 2023-03-03
    • 1970-01-01
    • 2016-05-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多