简体   繁体   English

如何将查询字符串重写为asp.net中的域?

[英]how can i rewrite query string to domains in asp.net?

how can i rewrite query strings to domains in asp.net and c# ? 如何将查询字符串重写为asp.net和C#中的域?

for example : 例如 :

rewrite 改写

http://www.site.com/site.aspx?SiteID=1001

to

http://www.WebSite1.com/

and

http://www.site.com/site.aspx?SiteID=1002

to

http://www.WebSite2.com/

I've seen some Blog providers do that 我已经看到一些博客提供商这样做

you create a blog , like http://example.blogspot.com and set up a domain , Your blog address is set to www.yourdomain.com 您创建了一个博客(例如http://example.blogspot.com)并设置了一个域,您的博客地址设置为www.yourdomain.com

I am not sure how to do this. 我不确定该怎么做。 But this is the idea behind it. 但这就是背后的想法。 I had worked on a similar project before 我之前曾从事过类似的项目

You should have a "Master" table, which contains the details of the user including which domain the user will use. 您应该有一个“主”表,其中包含用户的详细信息,包括用户将使用的域。 The domain should be pointed to your server IP. 该域应指向您的服务器IP。 When the user enters his domain in browser, the code should check the records which match the domain. 当用户在浏览器中输入其域时,代码应检查与该域匹配的记录。 You can also use different skins for your application. 您也可以为应用程序使用不同的皮肤。

What you are asking is more than just Url Rewriting. 您要问的不仅仅是URL重写。

In your pageload, check for the query string and redirect to the corresponding page. 在页面加载中,检查查询字符串并重定向到相应的页面。 It would be something like this: 就像这样:

if(Request.QueryString["SiteId"] == "1001")
Response.Redirect("http://www.WebSite1.com/")
else if(Request.QueryString["SiteId"] == "1002")
Response.Redirect("http://www.WebSite2.com/")

This is if you want to redirect. 这是如果您要重定向。 Else You would need to install rewriter module in IIS and then rewrite in web.config 否则,您需要在IIS中安装重写器模块,然后在web.config中重写

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

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