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.
Related
I have a currently existing site with URL re-writing enabled using ISAPI Rewrite and IIRF files, the problem is it's causing a lot of problems, both for site development / maintenance and because of continuous errors on the server.
Because of this I'm looking to replace it with .Net 4.0's URL Routing.
I'm having two problems with this, first, the current routing rules are set up so that the page being routed to is simply the re-written URL with the file extension appended to the end.
So www.site.com/page/ would become www.site.com/page.aspx
The second problem is that certain re-written URL's actually point to physical files within sub-folders on the website using the same logic as above.
So www.site.com/folder/page/ would redirect to www.site.com/folder/page.aspx
I've read through this article and created custom IRouteHandler and IHttpHander implemented classes, but I'm not really sure where to go from here.
I've tried a few different things, mainly related to variables in the URL and trying to redirect to them, but I'm not sure that's the right way for me to go.
I'm not posting code because all I have at the moment is pretty much the example code from the link above.
I've implemented basic routing on another site where a single page uses a variable in the URL to grab the relevant content out of a database, and that seemed simple enough, but this is making my head spin, I'm sure it shouldn't be this complicated.
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().
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.
I've got a website that was created about an year ago and its been constantly revised since then. The website is coded in classic ASP, contains about ~50 pages -- some are multi-purpose, and contains old-school style links such as:
/news.asp?PageIndex=4
/news.asp?SearchString=Obama
/news.asp?SearchString=Obama&PageIndex=4
/news.asp?NewsID=1
I have IIRF v2 installed which allows access to URL rewriting functionality so this I do not have to worry about. What I am worried about is how to replace about 300 links to .ASP pages with SEF urls. As far as my understanding is concerned, I have to add a database query (to extract title of the record being linked) for each link.
I need advice on how to begin converting the website into a SEF URL powered website with as little code change as possible. Wrapper classes and tried-and-tested techniques and pointers to best practices will be appreciated.
If you want to do URL Rewriting without changing frameworks or anything, may I suggest that you take a look at IIS7 Url Rewriting Module?
However, if you are rewriting part of your application in .NET ... you might want to consider ASP.NET MVC. It already build simple built-in URL Rewriting module and definitely allows you to keep on using your old "WebForms" (if ASP.NET) or your classic ASP pages.
Don't forget to permanently redirect each and every old link to a new one (use 301 HTTP code).
At news.asp (and whatever other old pages you have) put something (a class? I don't know, I have never used ASP) that parses the old-style URL and redirects (with a HTTP redirect code) to the new URL.
I'm not trying to be funny here but seriously how long would it really take to convert 300 links manually? I really suspect that it would take less time than trying to find some automated approach.
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