IIS URL重写对于%3D URL链接 [英] IIS URL Rewrite For URL Link with %3D

查看:138
本文介绍了IIS URL重写对于%3D URL链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有哪里有人张贴一个网址,像这样我的id参数后,包含%3D而不是等号我的asp.net MVC3网站的一个问题:的http://ultimategamedb.com/Article/Article?id%3D398210c1-529e-4909-9793-a11b8a832dcc 。我曾尝试过各种重写规则,但似乎无法网址正确改写为:的 http://ultimategamedb.com/Article/Article?id=398210c1-529e-4909-9793-a11b8a832dcc 。这是一个问题,因为与%3D的URL给出404错误。如果可能的话,我想创建一个与改写编码%到正确的去codeD值的任何URL的规则。如果这是不可能的我只是想知道如何重写我的文章的网址,以确保%3D将永远不会露面了equals在第六URL再次登录。

I am having an issue where someone has posted a URL for my asp.net mvc3 site that contains %3D instead of an equal sign after my id parameter like this: http://ultimategamedb.com/Article/Article?id%3D398210c1-529e-4909-9793-a11b8a832dcc . I have tried various rewrite rules but cannot seem the URL to rewrite correctly to: http://ultimategamedb.com/Article/Article?id=398210c1-529e-4909-9793-a11b8a832dcc . It is a problem because the URL with the %3D gives a 404 error. If possible I would like to create a rule that rewrite any URL with % encoding to the correct decoded values. If this is not possible I would just like to know how to rewrite my article URLs to ensure that a %3D will never show up for the equals sign in an Article URL again.

任何人都可以向我解释,我将如何去创造这些重写规则?在此先感谢!

Could anyone explain to me how I would go about creating these rewrite rules? Thanks in advance!

推荐答案

您有几个选择:


  1. 编写您自己的供应商将取代的%3D 的用的 = 的。

参考:<一href=\"http://www.iis.net/learn/extensions/url-rewrite-module/developing-a-custom-rewrite-provider-for-url-rewrite-module\" rel=\"nofollow\">http://www.iis.net/learn/extensions/url-rewrite-module/developing-a-custom-rewrite-provider-for-url-rewrite-module

的Application_BeginRequest ,更换你的路径:

protected void Application_BeginRequest(object sender, EventArgs e)
{
    string path = HttpContext.Current.Request.Url.PathAndQuery;

    // Search for %3D and replace.
    path = path.Replace("%3D","=");

    HttpContext.Current.RewritePath(path);
}


这篇关于IIS URL重写对于%3D URL链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆