redirect from old page - 302, 303 or 403 forbidden - redirect

I create the site about realty.
It has three page about one item (flat)
/flat/item/1 -main page about flat
/flat/gallery/1 -photos
/flat/map/1 -map
Customer wants that if flat is out of stock then two pages(gallery, map) have unaccesible for view.
I want to know. What kind of status code I have to set 403 or 404?
May be 302, 303 and redirect to /flat/item/1?

If you don't want to redirect, you should be using 410 ("Gone"). This means that the resource is permanently no longer available.
If you want to redirect the gallery and map to the main page, use code 301 ("Moved Permanently").

Related

Jmeter 302 instead of 200

I have two request in 1st request is giving me 307 redirect along with location header.
I pull Location header from response headers of 1st request and then passed it to second request.
Now 2nd request is giving me 302 every time.
I tried to play with follow request / redirect automatically options in 1st and 2nd request. However it didnt help. I checked both requests shows Https, I checked cache manager it is working fine.
Played with some settings related to Cache Control still issue is occurring.
2nd request is responsible for generating phpsessionid as 'set-cookie' which will only come when 200 OK will happen.
If anyone has any workaround, please assist. Thanks.
As per HTTP Status 302
The HyperText Transfer Protocol (HTTP) 302 Found redirect status response code indicates that the resource requested has been temporarily moved to the URL given by the Location header. A browser redirects to this page but search engines don't update their links to the resource (in 'SEO-speak', it is said that the 'link-juice' is not sent to the new URL).
so my expectation is that you need to play the same trick as with the 1st request, to wit extract the redirect URL from the Location header and add 3rd HTTP Request sampler to hit that URL
In general a "good" JMeter test should behave exactly like a real browser so you should cross-check JMeter's network footprint with what is in the "network" tab of your browser developer tools and amend JMeter's configuration so it would send exactly the same requests as the browser does.

HTTP Status Code for Resource with Multiple URIs

Which HTTP status code should be used when redirecting from a secondary URL to a primary URL?
For example, if the "official" URL of a Contact page is /contact-us and I want to provide /contact as a shorthand convenience, what would be the appropriate status code?
Use one of these:
301 Moved Permanently
302 Found
303 See Other
From your question I think 303 See other is most appropriate.

how to jump from one page to another page in bottle?

In bottle, how to jump form one url to another url in one page?
import webbrowser
webbrowser.open('http://localhost:8080/login.html')
I tried like above, but it's not been opened in one page! I want it to be redirect, but not raise 303 or 302 error!
It sounds like maybe (?) you're looking for a way to redirect incoming HTTP requests. You mention not wanting to return a 302 or 303 (why not, exactly?), so here's how you'd do it with a 301 ("Permanently Moved"):
#route('/hello')
def hello():
bottle.redirect('/the/destination/page', 301)

Response.Redirect() vs Response.RedirectPermanent()

I am new to ASP.Net 4.0, and have seen a new feature called Response.RedirectPermanent(). I have checked a few articles, but I'm unable to understand clearly the actual meaning and difference of Response.RedirectPermanent() over Response.Redirect().
According to Gunnar Peipman,
Response.Redirect() returns 302 to browser meaning that asked resource is temporarily moved to other location. Permanent redirect means that browser gets 301 as response from server. In this case browser doesn’t ask the same resource from old URL anymore – it uses URL given by Location header.
Why do I need to check the server response such as 301, 302? And how does it get permanently redirected the page to the server?
301 response (RedirectPermanent) is very useful for SEO purposes. For example, you had a site implemented in ASP.NET WebForms and redesigned using ASP.NET MVC. You'd like to inform search engines that page /Catalog/ProductName.aspx becomes /products/product-name. Then you set 301 redirect from /Catalog/ProductName.aspx to /products/product-name and links in search engines' indices will be replaced. 302 (Redirect) is mostly for internal purposes. For example, the redirect after login (if returnUrl was set in URL).

How to redirect after a successful DELETE request

I have an HTML form performing a DELETE request (method = POST & hidden X-HTTP-Method-Override = DELETE)
When the DELETE request is successful, how do I tell the browser to redirect to another page?
Is 303 + header location okay?
Currently, the browser doesn't display the empty response but keep the previous response (I guess because of the 204 status code).
If I add a location header (still 204 status code) it does not change the location.
With 303+location I have the desired behavior but I wonder if 303 is a valid status code after a successful DELETE.
What about 202 (Accepted) DELETE ?
303 plus Location is the best choice. Don't worry about what a "successful DELETE" is or means, because you're using POST, which has a different set of semantics, and 303 is tailor-made for redirecting POST requests:
10.3.4 303 See Other
The response to the request can be found under a different URI and SHOULD be retrieved using a GET method on that resource. This method exists primarily to allow the output of a POST-activated script to redirect the user agent to a selected resource. The new URI is not a substitute reference for the originally requested resource. The 303 response MUST NOT be cached, but the response to the second (redirected) request might be cacheable.