how to rewrite my URL

Posted by Shameer.Ali87 under ASP.NET on 7/24/2012 | Points: 10 | Views : 1172 | Status : [Member] | Replies : 2
I am working with .net frame work 3.5 with asp.net & c#

i have folders in my project named iPhone, ipad and desktop...

if the request is coming from desktop, then it will redirect to http://www.example.com/ (as a general website) &
if the request is coming from iPhone... then it should redirect as http://iphone.example.com/ instead as http://www.example.com/iphone/

in the same way it should work for ipad also...

here the URL prefix should change from 'WWW' to 'ipad' or 'iPhone' depending on the request.. and i kept all the ipad, iPhone related pages in the corresponding folders, so it should stay with in the same web server, but only the URL should change..

i.e., for example, if request is coming from ipad, then it should redirect as

http://ipad.example.com/ipad/home.aspx..

before doing this, I checked from where the request is coming, i.e., using the userAgent , now if the request is coming from ipad,
then it should redirect as above..


please help me
thanks

shameer ali shaik


Responses

Posted by: Sheonarayan on: 7/24/2012 [Administrator] HonoraryPlatinum | Points: 25

Up
0
Down
If I understand your question correctly, you must be checking this in global.asax (from where the request is coming), there simply use the switch case to redirect the user to corresponding pages.

like
switch (userAgen)

{
case "iphone":
Response.Redirect("http://iphone.domain.com/home.aspx");
break;
case "ipad":
Response.Redirect("http://ipad.domain.com/home.aspx");
break;
default:
Response.Redirect("http://www.domain.com/home.aspx");
break;
}


Hope this helps.

Regards,
Sheo Narayan
http://www.dotnetfunda.com

Shameer.Ali87, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Shameer.Ali87 on: 7/24/2012 [Member] Starter | Points: 25

Up
0
Down
thanks for your answer..
as per your answer it may redirect the user to the corresponding pages,
but here i want only the prefix of the URL to be changed, i.e., for example (http://ipad.domain.com/home.aspx),
here the ipad should be added from the corresponding folder name only, and it redirect as
http://ipad.domain.com/ipad/home.aspx/

thanks for your answer once again..
please help me little clearly..
as i am new to .net programming,

thanks


shameer ali shaik

Shameer.Ali87, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response