简体   繁体   English

ASP.NET:如何在斜杠后重写URL

[英]ASP.NET: How to rewrite URL after slash

I have a website that has language options of which one is turkish (tr). 我有一个网站,该网站的语言选项为土耳其语(tr)。

The problem is that I deleted the language in the website (end user can no longer check the site in turkish) BUT the links can still be consulted via Google. 问题是我删除了网站中的语言(最终用户无法再以土耳其语检查该网站),但是仍然可以通过Google来访问链接。

An example link looks like: http://example.com/page2.aspx?lang=tr . 链接示例如下: http : //example.com/page2.aspx?lang=tr

What I want to do to solve this, is to redirect all requests to ?lang=tr to my homepage ( http://example.com ). 为了解决这个问题,我要做的是将所有对?lang=tr请求重定向到我的主页( http://example.com )。

Is this achievable via URL rewriting? 通过URL重写可以实现吗? How would I do this? 我该怎么做?

I have checked it in rewrite module but didn't came further than this: 我已经在重写模块中检查了它,但没有超出此范围:

  <rewrite>
            <rules>
                <rule name="Test" patternSyntax="Wildcard">
                    <match url="?lang=tr" ignoreCase="true" />
                    <action type="Redirect" url="{R:1}?lang=en" appendQueryString="false" />
                    <conditions logicalGrouping="MatchAny">
                    </conditions>
                </rule>
            </rules>
        </rewrite>

试试这个<rewrite> <rules> <rule name="Test" stopProcessing="true"> <match url=".*" /> <action type="Redirect" url="/" appendQueryString="false" redirectType="Permanent" /> <conditions> <add input="{QUERY_STRING}" pattern="lang=tr" /> </conditions> </rule> </rules> </rewrite>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM