I am trying to wrap my head around a URL rewrtie / redirect project I need to work on. We currently have this url: http://www.example.com/Details/Detail.aspx?param1=8¶m2=12345
Here is what the rewritten URL will look like: http://www.example.com/Param1/8/Param2/12345
I am using the ISAPI_Rewrite filter to allow for the "nice" url and make the page think it is still using the old url. That works fine.
Now, I need to redirect users, if they use the old URL, to the new URL. I figure I would need to use a combination of the filter and an HTTPModule / Handler to perform the redirect.
Any ideas?
Have you tried IIS URL Rewrite?
If you are not going to go down the System.Web.Routing (or use ASP.NET MVC) path then I would have a look at this link.
Using a HttpHandler would be your best bet. That way, you will be able to track all incoming requests, filter out the old format URLs and redirect them to the correct pages.
Related
I need to redirect 1000's of URL's of the following format:
http://egauges.com/vdo_mult3.asp?Type=Ammeter&Series=Vision&Units=E
to a new Volusion (unfortunately) ASP.net site with the format
egauges.com/Ammeters-s/22044.htm
Which is actually here for now (http://gnqvn.mzqlg.servertrust.com/Ammeters-s/22044.htm)
The old site will go away once this is working, so redirects must be done on the new site.
Volusion has a 301 redirect "tool", but unfortunately it can't handle anything after the ? in the original URL. Volusion kicked it up the chain in their tech support, but says there isn't a way to do it. I'm sure some sort of script, either server or client side, or maybe even something simpler would work, but despite searching high and low, I can't figure it out.
Thanks!
Dave
Do the redirect directly in the asp site.
Change vdo_mult3.asp so that it redirects anyone who accesses it by using Response.Redirect as follows:
Response.Redirect("http://egauges.com/Ammeters-s/22044.htm")
You can also check the parameters passed to and change the redirect passed on those parameters.
How can I acheive bi direction rewriting to where the following occurs inbound to the web server
www.mysite.com/region/program/cat1/cat2/cat3
sends the request to the server
www.mysite.com/program.ASPX?idregion=(regionlookupnumber)&idcategory=3276
and when the server is going to write the above it converts it the other way.
Bi-directional URL rewriting on IIS7 using the URL rewriting package. We don't want to modify the source code if possible.
Any advise or resource or sample link please?
I did this using the automatic friendly url template of the url rewriting package 2.0
It works really well. You just need to make sure to only re-write the urls you really need to. If you re-write img, link, etc. tags for instance, it can break your page.
I have to make all links SEO friendly on our website.
I have the following url: http://newark.storeboard.com/board.asp?RegionID=353&ClassAdCatID=740&IsEvent=1&IsCoupon=0&IsBlog=0
I need it be: http://neward.storeboard.com/classifieds/events/ConcertsLiveMusic
I have no way of accessing the IIS so this has to be done thru code. Any ideas about how to achieve this would be greatly appreciated.
Many Thanks,
Paul
The standard way of solving this as far as I know is to use a rewrite engine in IIS (such as ISAPI_rewite or IIS7 url rewrite module)
However, you don't have access to IIS you say... That makes it tricky. Two thoughts come to mind:
1) Could you create a dynamic (asp) 404 page that then looks at the request header and does a transfer according to the page requested?
2) Or, and this is rather lame, could you create a static folder structure that goes some way to looking like that url structure?
If you upgrade to IIS7 and use ASP.Net then you can control the URL rewrite module from your code.
I've done something similar to Matts suggestion 1 in the past and it can work. The important thing is you make the 404 page directly feed the true page content and not do a redirect. Otherwise your defeating the point of SEF URLs for SEO gain.
From the few references I still have to the code. asp has a Server.Transfer() function but you may have issues that you can't pass query string parameters. I think I ended up streaming the real page through the 404 page using the MSXMLServerXMLHTTP object and Response.BinaryWrite().
Most of the resources on the Internet seems to discuss how to do url rewriting in asp.net. None of them seem to discuss about how to read the rewritten url.
For example, I have rewritten:
http://www.test.com/users.aspx?id=12&name=sangam
to
http://www.test.com/profile/12/sangam.aspx
Now in the same page, at some point, I want to get this rewrittern url for the purpose of pointing return url in login link. Now a login link should be:
http://www.test.com/login.aspx?ReturnUrl=/profile/12/sangam.aspx
What is the proper way to achieve this? Thanks.
Try Request.RawUrl
I am trying to redirect a user when they entire a URL in this format:
http://example.com/http://example2.com/
To the following:
http://example.com/?m=example2.com#http%3A%2F%2Fwww.example2.com%2F
I want to strip out the host of example2 and make it a query-string, then URL encode the full URL of example2 and put it as the anchor.
What is the best way to do this in asp.net? I can use mvc, iis7, or iis6. I know I could do this by mapping everything to .NET in IIS6 and then using httpcontext.rewritepath but I bet there is a better way.
Thank you.
Unfortunately, ASP.NET does not allow a colon anywhere in the URL path. Not even an escaped colon (%3A). It is only allowed in the querystring portion of the path.
This restriction is in place even before URL rewriting happens. (You'll get the 400 Bad Request error.) In that question, the asker answered their own question with a link to Stefan from the ASP.NET team.
Of course, you can still collect the URL from your user any way you like, and format the URL or redirect in a way that ASP.NET can use.
What do you think about urlrewritting concept of ASP.net. I think it can solve your purpose