RewritePath / Server.Transfer (~ issues in Module) RRS feed

  • Question

  • User623377534 posted
    Hi Everyone, I am working on a project that uses an HTTP Handler to dynamically resize/cache images, along with an HTTP Module which ensures SSL usuage on specified pages. The project is an E-Commerce site which also dynamically creates all the Meta data, page titles, and image alternate tags from info pulled from the database.. needless to say being nice to search engines is a requirement of this project. So.. On some pages, mostly product browsing pages, my URLs have 3 variables in the querystring. http://localhost/myproject/products.aspx?department=1&category=2&product=123 .. not good for crawling.. So, I developed a method in my HTTP module to rewrite it to http://localhost/myproject/department/1/category/2/product/123/products.aspx which should be nicer to a crawler. I am experiencing problems with my links that have the ~ in them, which I searched the forum and I can see whats up with that. So instead of Context.RewritePath() I tried Server.Transfer() and it seems to work well. AFAIK there is no redirect (which i MUST avoid, as search engines get pissed by that?). Can someone confirm this? is Server.Transfer() ok as far as search engines are concerned? Is Server.Transfer() ok as far as performance (compared to RewritePath that is). If Server.Transfer() is slow compared to Context.RewritePath() is there a graceful way of making the ~ links translate properly? If Transfer() is fine, I will just stick with that though :) Thanks in advance !
    Wednesday, April 28, 2004 9:15 PM

All replies

  • User-1391363652 posted
    Can you replace the tilde with some kind of a base url? How about a regex that does that? I'd recommend RewritePath over Server.Transfer. The reason is RewritePath doesn't cause a detour and is therefore faster. Also, it allows you to "obfuscate" the real URL. Server.Transfer sends a 302 and reveals the real URL. Note that Server.Transfer throws a ThreadAbortException every time. Well, it's the result of calling Response.End, to be more precise. If your site facilitates a lot of traffic throwing too many exceptions might create overhead (exceptions are expensive). It's questionable if search engines hate redirects. Most people believe (including myself) that SEs hate too many excessive redirects, but this is not carved in stone. Same goes for the notion that SEs dislike dynamic content---there's no proof either way.
    Wednesday, April 28, 2004 10:07 PM
  • User623377534 posted
    I suspected that. Ok, I am going to have to create a helper function to translate that ~ into the real application root. i am not sure why it appends the path after the fake URL.
    Thursday, April 29, 2004 1:47 AM
  • User-1645088262 posted
    Hi Sharbel I have a HttpModule that does exactly what you describe. Just email me if you'd like a copy (simon@intesoft.net)
    Thursday, April 29, 2004 6:56 AM
  • User623377534 posted
    Thanks Simon, I will email you right now. I would like to look at your code for some ideas.
    Thursday, April 29, 2004 9:07 AM
  • User623377534 posted
    Hmm I am having trouble finding a way to determine if the requested file has the ~ in it.. I would think I would have to add a .* mapping in my IIS configuration for that site to the asp_net.isapi so that all requests will run through it, which I can do. However, I still cant seem to capture if the requested file/image has a "~" in it, so I can replace it with the true applicaiton path (instead of the rewritepath+the app path) I suppose I could just make everything /images/imagname.jpg instead of ~/images/imagename.jpg but I would really like to keep it in the Application Root instead of the server root
    Thursday, April 29, 2004 10:52 AM