Wagtail return 301 or 404 status code instead of the default 410 for unpublished pages - wagtail

Wagtail returns the default 410 status code when the page is unpublished. Is there a way to return 301 status code with redirect or just 404 for unpublished pages?
The reason is as follows:
Since Google still treats 404 and 410 errors differently, you need
to use the 410 code only when you know for sure that the page has been deleted and
will not return. This response is cached by default, the search robot
no longer visits the page, and it, in turn, is removed from the index.

Related

How to create a 302 GET request with postman?

In postman I want to create a GET request that returns a 302 status code (along with a Location response header). I have been trying to replicate the original request from the browser inspector, but I always get a 200 response (and no Location response header).
How can I get the desired response with the Location response header?
Please try to turn off automatical redirects (File->Settings: General Tab):
What is probably happening is that Postman receives a 302 status code, but is configured to redirect in this case, so it automatically redirects after which Postman receives a 200 status code, which is what you end up seeing.
Apparently turning off "automatically follow redirects" should offer you a solution.
https://learning.getpostman.com/docs/postman/launching_postman/settings/
View postman request when redirects

Request filter mechanism in React

Is there a mechanism in React to filter/interceptor request.
Eg. For specific URL, i want to do some flag check and depending on flag I want to do 404, 301 redirect. Else 200 OK normal page.

Azure random 404 on valid URL in Application Insights

My website uses AngularJS (v1) with webapi. I have a file upload directive that posts to my file upload controller. On some calls to the file upload, I get a 404 not found on a valid address. Most of the time it works as expected. If I look through the Application Insights on Azure, I can see some weird reporting in regards to the file upload api. See images
In the first image in the left column, I can see 8 errors reported with a POST to /api/fileupload/upload. Middle column shows all 8 are 404s, and in the third column, I can see the request URL, which if I copy and paste into the browser, doesn't return a 404 (returns a 405, method not allowed which I'd expect as it doesn't support GET requests but it does find the url).
The second image shows a valid api request (this error is expected). The left column shows a POST to fileupload/upload (NOT /api/fileupload/upload/ as in the first image that 404s), but the middle and left columns show the same request URL as the 404 in the first image.
In angular, I only call the API from one spot in my file upload directive:
angular.element($element).fileupload({
url: 'api/fileupload/upload/',
type: 'POST',
...
...
});
What are these 404s? How can I stop them? How can I find out where its going wrong?
Regarding calls to upload resulting in 404: it is a known issue that ASP.NET can return 404s when attempting to upload files that exceed allowed size. See here for more details.
Regarding the error on your second image, it is unclear from your question, whether these are expected, or not, but to note - this is 400, not 404 and 400s can be thrown for invalid routing.

Why are custom 404 handlers not supported in Google App Engine?

I'd like to send a 404 error, and re-direct to a more attractive Error page for the user on Google App Engine.
I've tried adding this to my web.xml, but it doesn't work
<error-page>
<error-code>404</error-code>
<location>404.html</location>
</error-page>
The only information I have discovered comes from the old Google group
https://groups.google.com/d/topic/google-appengine-java/3C-pY5ta2HQ/discussion
I'd like to send the proper 404 header for search engines, and I'd like to present a nicer Error message to the user. Jason's suggestion at the end would mean sending a 302 and not a 404 so I don't think that is ideal for search engines. Is that the only choice? Any help, views appreciated.
Custom 404 pages are not supported for URLs your app handles, because once the request is directed to your application, it's up to it to return the response to the user. If you want to render an attractive 404 page, you should have your app return that as its response to a request that generates a 404. How you do that - via an internal redirect (not an HTTP one!) - or other functionality is up to you.

TYPO3: 404 not rewriting URL

So Im having quite trouble to get speaking URLs in TYPO3. I managed to make them work with this 2 lines in localconf.php
$TYPO3_CONF_VARS["FE"]["pageNotFound_handling"] = 'http://www.mysite.com/';
$TYPO3_CONF_VARS["FE"]["pageNotFound_handling_statheader"] = 'HTTP/1.1 404 Not Found';
But the problem is that if I type a inexisting page, it even though it will direct me to the homepage, it wont rewrite the URL in the browser. Is there something that can be done about this?
It's the correct behavior of 404 not to change the URL in the browser. For redirects we have 30x http status codes. But you can't send two http status codes at the same time (404 and 301).
It is kind of bad practice to redirect to a homepage instead of showing a 404-not found message. The users may be irritated, asking themselves why they are now on the homepage and not at the URL they typed in...

Resources