When a user browses to http://mysite.com, I want the server to automatically do a serverside 301 redirect to http://www.mysite.com
I have heard that this is possible in the global.asax file, but I don't know much about it. Can someone help me with a simple example of how this would be done?
Thanks,
DanHello, what you can do is: in ur index.aspx page add this:
Server.Transfer("http://www.mysite.com");
do u need more than this ?
Or do you want the url to be physically updated in the browser? I believe you can do this in IIS (I know you can do it in apache), but sorry I wouldn't know how to do it. Find some IIS gurus :-)
Well, actually, I have two questions. Let me try and explain better.
1) If a user types in http://mysite.com OR http://mysite.com/pages/page1.htm ETC... (basically they browse to any URL on my site, WITHOUT www. in front of it) I want the global.asax to look at the URL that has been requested and search for "http://www." in the query string. If it is not there, I want it to put the www. into the request in the proper place and do a server side 301 redirect.
2) I am now also wondering if it is possible to handle this scenario : a user browses to the following URL : http://www.mysite.com/page/page-1.html. I want the global.asax page to take the requested URL and display the contents of a different URL http://www.mysite.com/page/showthemthis.aspx, but at the same time keeping the "http://www.mysite.com/page/page-1.html" URL in the users browser window.
Can the global.asax handle either of these situations? I am more concerned about handling situation #1, but am just curious about situation #2.
Thanks,
Dan
No comments:
Post a Comment