实时网站上的网址重写问题. [英] Url Rewriting issue on live site.

查看:110
本文介绍了实时网站上的网址重写问题.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我最近一直在为我的网站开发博客引擎,遇到了一个问题,即与开发机器相比,我的实时网站上的URL不同.

我正在使用自定义网址编写器将SEO友好网址重新映射到所需页面.

例如:http:///:empirical-design.com/posts/building+a+better+web.aspx

应该重新映射到:

http://www.empirical-design.com/post.aspx?id=19fe4e9c-135d-4570-9cad-a8d5b8c683df

在我的开发机器上,这按计划进行.页面上的任何回发都将注册到

http://localhost:53022/post.aspx?id = 19fe4e9c-135d-4570-9cad-a8d5b8c683df并且客户端回调正确指向,允许我使用ICallbackEventHandler预览或向站点添加评论.

在实时服务器上,发生的任何回发都将注册到
http://www.empirical-design.com/posts/post.aspx?id=19fe4e9c-135d-4570-9cad-a8d5b8c683df

如您所见,它是在URL中插入额外的路径"/posts/".

我已经在萤火虫中检查了发布结果以确认这一点.

本地:
POST http://localhost:53022/post.aspx?id = 19fe4e9c-135d-4570-9cad-a8d5b8c683df

现场直播:
POST http://www.empirical-design.com/posts/post.aspx?id=19fe4e9c-135d-4570-9cad-a8d5b8c683df

在我的httpModule im中使用

Hi all,

I''ve been working on a blogging engine for my site recently and have hit accross an issue with urls being different on my live site when compared to my development machine.

I''m using a custom url writer to remap SEO friendly urls to the required page.

For example: http//:empirical-design.com/posts/building+a+better+web.aspx

should remap to:

http://www.empirical-design.com/post.aspx?id=19fe4e9c-135d-4570-9cad-a8d5b8c683df

On my development machine this is working as planned. Any postbacks on the page are registered to

http://localhost:53022/post.aspx?id=19fe4e9c-135d-4570-9cad-a8d5b8c683df and the client callbacks are pointing correctly allowing me to preview or add a comment to the site using the ICallbackEventHandler.

On the live server any postbacks occurring are registering to
http://www.empirical-design.com/posts/post.aspx?id=19fe4e9c-135d-4570-9cad-a8d5b8c683df

As you can see it is inserting the extra path "/posts/" into the url.

I''ve checked the post results in firebug to confirm this.

Local:
POST http://localhost:53022/post.aspx?id=19fe4e9c-135d-4570-9cad-a8d5b8c683df

Live:
POST http://www.empirical-design.com/posts/post.aspx?id=19fe4e9c-135d-4570-9cad-a8d5b8c683df

In my httpModule im using

context.RewritePath((String.Format("{0}post.aspx?id=", VirtualPathUtility.ToAbsolute("~/")) + objPost.Id.ToString() + GetQueryString(context), False)



重新标记网址(VB).我无法一辈子正确地理解这一点.有人有什么想法吗?

提前非常感谢.

更新**************
感谢Abhishek Sur提供您的信息.我正在使用context.RewritePath,但它需要虚拟路径,因此我不能使用绝对URL(我错过了什么吗?



to rewite the url (VB). I can''t for the life of me get this to factor correctly. Does anyone have any ideas?

Many thanks in advance.

Update**************
Thanks Abhishek Sur for your input. I''m using context.RewritePath though which requires a virtual path so I can''t use the absolute Url (have I missed something?

推荐答案

是的,我知道,

UrlRewrite总是使我感到烦恼.如果它在debug env中可以正常工作,则会在原始服务器中产生问题.

因此,在执行此操作时,我始终使用安全编码.我在本地重新创建整个路径,然后重定向.

我会用:
Yes I know,

UrlRewrite always bugs me.. If it works correctly in debug env, it create problems in the original server.

So While doing this I always use Safe coding. I recreate the whole path locally and then redirect.

I would have used :
context.Request.Url.Scheme + "://" + context.Request.Host + ":" + context.Request.Port + yourpath<br />

[请注意在更新前先进行检查]

这将确保您的应用程序可在所有环境中正常工作.
:rose:

[Note to check this before update]

This would ensure that your application is working in all environment.
:rose:


刚刚找到了解决我问题的方法.

http://weblogs.asp.net/jezell/archive/2004/03/15/90045.aspx [ ^ ]

出色的东西,也很容易理解.感谢您阅读我的问题.
Just found the solution to my problem.

http://weblogs.asp.net/jezell/archive/2004/03/15/90045.aspx[^]

Remarkable stuff and easy to understand too. Thanks for reading my question.


非常感谢,我也遇到了同样的问题.我将看看您的答案是否也可以进一步解决我的问题.
Thanks so much, I had the same problems with mine. I am going to see if your answer can further solve my issue as well.


这篇关于实时网站上的网址重写问题.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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