复合C1-“ URL别名”,使用Querystring重定向URL [英] Composite C1 - 'URL Aliases', redirecting URL's with Querystring

查看:112
本文介绍了复合C1-“ URL别名”,使用Querystring重定向URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Composite C1 CMS网站。

I have a Composite C1 CMS site.

要维护SEO功能,我需要重定向一些旧的-主要是博客URL-例如: http://www.mydomain.com/en/news/news.php?b=68

http:/ /mydomain.com/zh-CN/Blog/2013/04/30/Friendly-Article-Name

To maintain SEO juice, I need to redirect some old - mainly blog URLs - like this: http://www.mydomain.com/en/news/news.php?b=68 to http://mydomain.com/en/Blog/2013/04/30/Friendly-Article-Name

http://www.mydomain.com/en/ news / news.php?b = 69

http://mydomain.com/en/Blog/2013/04/30/Another-Friendly-Article-Name

大约有100个重定向链接。

There are about 100 links to redirect.

URL别名模块似乎运行良好,直到您添加查询字符串(上面的?b = 68)为止-然后它将停止工作。

The 'URL Aliases' module seems to work well, until you add a querystring (?b=68 above) - then it stops working.

如何重定向多个identi校准的URL,每个URL都有不同的查询字符串?

How can I redirect several identical URL's, each with a different querystring?

推荐答案

这绝对是Url Aliases软件包中的错误。

That is definitely a bug in the Url Aliases package.

解决此问题的最快方法可能是滚动自己的http模块,至少要等到发布修补程序为止。
您可以从GitHub上程序包的仓库中获取源代码,并对其进行调整以解决此问题,并确保从web.config中取消注册捆绑的http模块并注册自己的模块。

The quickest way around this would likely be to roll your own http module, at least until a fix is published. You can snag the source from the package's repo on GitHub and tweak it to fix the issue, making sure that you unregister the bundled http module from web.config and register your own instead.

当前的http模块源位于此处: https://github.com/CPHCloud/c1packages-urlaliases/blob/v1.0.2/CphCloud.Packages.UrlAlias/UrlAliasHttpModule.cs

The current http module source is here: https://github.com/CPHCloud/c1packages-urlaliases/blob/v1.0.2/CphCloud.Packages.UrlAlias/UrlAliasHttpModule.cs

更改 incomingUrlPath 的值以使用 PathAndQuery 代替 AbsolutePath ,像这样:

Change the value of incomingUrlPath to use PathAndQueryinstead of AbsolutePath, like this:

...
static void httpApplication_BeginRequest(object sender, EventArgs e)
    {
        var httpApplication = (HttpApplication)sender;
        var incomingUrlPath = HttpUtility.UrlDecode(httpApplication
            .Context.Request.Url.PathAndQuery.TrimEnd(new[] { '/' }));
....

在您的web.config文件中,您应该注销Url ALiases的处理程序

In your web.config file you should unregister Url ALiases' handler

<!--add name="UrlAlias" type="CphCloud.Packages.UrlAlias.UrlAliasHttpModule,
  CphCloud.Packages.UrlAlias, 
  Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" /-->

并注册自己的

<add name="CustomUrlAlias" type="CphCloud.Packages.UrlAlias.UrlAliasHttpModule, 
  YourAssemblyName, 
  Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/> 

全部披露:我是URL Aliases软件包的作者。

Full disclosure: I'm the author of the URL Aliases package.

这篇关于复合C1-“ URL别名”,使用Querystring重定向URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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