We are working in a project which uses Symfony2 + AngularJS.
Each one in a different domain (api.domain for Symfony2 and www.domain for the Angular project).
Now we are focusing on the SEO part. We use Prerender.io to create static snapshots to serve a good HTML Raw page to crawlers.
But the problem is when serving the "404 Page" on Angular:
$urlRouterProvider
.otherwise('/404');
The thing is, what we do is redirecting a nonexistent page to our "404 Page" with a 200 Header Status Code, which is very bad for SEO purposes...
Since AngularJS is not capable of generating, we have already tried 2 things:
1. Use a redirection with htaccess / Apache:
RedirectMatch 404 "/404"
2. Call to a web service which return us a 404 error:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html>
<head>
<title>404 Not Found</title>
</head>
<body>
<h1>Not Found</h1>
<p>The requested URL /do-not-access was not found on this server.</p>
</body>
</html>
And for the AngularJS side we tried to throw the header status code without success:
return $http.get(ENV.apiEndpoint + '/do-not-access');
None of this worked for us...
We also though about using a second "404 Page". The idea was redirecting our first 404 page to this second 404 page via htaccess with a 404 status code, but we think that will not work due to AngularJS internal redirection:
200 -> 301 -> 404
PS: I found: AngularJS html5mode and hard 404 which says "we have to configure our server to make a routing exception for your custom 404 page" but we really have no clue how to do it...
Are we focusing in a bad way?
There is other option?
How we can handle it?
Any ideas?
It seems that prerender.io offers a way to handle http header status.
For example, for a 404 page we just need to add this meta tag into our head tag:
<meta name="prerender-status-code" content="404">
Docs: https://prerender.io/documentation/best-practices
Related
I have a custom 404 page and its working fine. When the user has a non existed url, lets say example.com/abcd, they are redirected to the 404 custom page. But the 404 custom page has 200 status code, that is not good for SEO. And as I read some information, this is normal behaviour because the 404 page exists.
But is there any chance to make this page to return 404 status code?
Gatsby version is 2.17.11.
I thought of making a 404 Page. but it seems hard.. how do i do it?
Here's what I did:
Made .htaccess File
Put: ErrorDocument 404 /page-not-found.html inside of the .htaccess file..
Added css design
Why doesn't it work?
I use glitch as my coding website. Is that the problem?
Is there an alternative way to do this.?
If you want a custom 404 page for an app on Glitch, you'll need to be building a Node/full-stack app and configuring the page in your server-side code.
For example, I've got this simple Express app that sends any non-index route request to a 404 page: https://glitch.com/edit/#!/tranquil-hurricane-friction?path=server.js%3A25%3A0
I try to add a 404 page into my angularjs project which is hosted on firebase servers. I created a custom 404 page and added following code:
function routeConfig($stateProvider, $urlRouterProvider, $locationProvider)
{
$urlRouterProvider.otherwise('/pages/errors/error-404');
}
Now it works but I am missing something because when I check in the browser's network panel the status code is "200" but it should be "404".
What should I do for that?
$urlRouterProvider.otherwise just guides AngularJS that which URL it should navigate to when no URL matches the provider's rules.
This doesn't signify that a resource is not found on the server (which essentially returns 404). To do that, you need to do a lot more including serving this 404 page from the server with 404 as the status code.
Here is a resource to point you in the right direction:
AngularJS UI router handling 404s
I am trying to get my AngularJS with html5mode enabled indexed by google.
In my app.js I have the following snippet:
$locationProvider.html5Mode(true);
In my index.html head I have the following:
<base href="/"/>
<meta name="fragment" content="!"/>
I expected to get requests on urls of the format /?_escaped_fragment_=support. Instead I'm getting requests on /support?_escaped_fragment_=.
Is there something wrong with my config or did I expect something weird?
according to the yearofmoo SEO article you should get this:
http://yourwebsite.com/?_escaped_fragment_=/some/page/with/ajax/content
YearofMoo - SEO
I am trying to validate the HTML on my 404 page for a WordPress theme, but obviously, the validator cannot find the page, because it doesn't exist.
http://cambridgeuplighting.com/agsdfachgsd
http://cambridgeuplighting.com/404a234
Or any false link will generate the 404 page, but what's the actual url for this page?
Thanks!
Most systems don't expose a 404 error page with a 200 status code. Tick the Validate error pages option at http://validator.w3.org/#validate_by_uri+with_options instead.
There isn't one, really. Your best bet is:
find the bit in Wordpress which sets the 404 header and comment it out. (I gave it a quick go, but failed)
If you're using firefox, install this addon: https://addons.mozilla.org/en-US/firefox/addon/249 which will validate the page inside the browser. (This seems to be the same kind of thing for Chrome, but I haven't tried it: https://chrome.google.com/extensions/detail/cgndfbhngibokieehnjhbjkkhbfmhojo )
download the pure HTML for the page and upload it.