开发者

Is there such thing as a HTTP URL re-write without 301 or 302 redirect?

Is there such a thing?

A way it might be used:

Many locations have forms that post to http://www.example.com/wally/app/receiver.aspx

Managements decides they want a cleaner URL and there is no reason to pretend you are using aspx (you didn't really think I was using aspx for that did you?)

They say it should be http://example.com/receiver

Easy enough! Just put a 301 redirect. No need to update all those forms that exist all over..,, but wait.. You can't do that for POST.

Perhaps you can receive and handle the request and then re-wri开发者_开发问答te the URL without causing a subsequent request? Perhaps this will not strip the www (cross domain), but can it shorten the pathname like that without a separate request?

Even in GET requests, this would indeed be a performance boost if one could re-write the URL and send the response body at the same. Can this be done?


  1. You cannot send content to user and do 301/302 etc redirect at the same time -- browser interprets the HTTP Response code and acts accordingly to the code received. If 301/302 -- it will do redirect, if 200 -- will display it to the customer.

  2. Is there such thing as a HTTP URL re-write without 301 or 302 redirect?

    Yes -- it's called rewrite (internal redirect). For example -- customer requests http://example.com/receiver. You rewrite URL to point to /wally/app/receiver.aspx (e.g. RewriteRule ^receiver$ /wally/app/receiver.aspx [L] -- that's if you have an Apache, which you most likely not (considering receiver.aspx)). This will do internal redirect when URL remains unchanged in browser address bar (works fine with POST and GET methods).


Well, I guess rewriting url suggested by LazyOne is not the answer to the question as he himself states that

This will do internal redirect when URL remains unchanged in browser address bar

(http://www.example.com/wally/app/receiver.aspx). Still, the question asks for

(...) it should be http://example.com/receiver

I think the solution is to redirect old url to the new one using 307 status code introduced in RFC 2616. User agents which handle version 1.1 of HTTP protocol (I guess all popular browsers for some time now) should make the new request using the same http method (POST in this case) as in the original request.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜