Hi,
Is it possible to redirect all broken 404 pages to home or some other page automatically?
Regards
Hi,
Is it possible to redirect all broken 404 pages to home or some other page automatically?
Regards
Since Discourse doesn’t use htaccess, I am not sure where to look for a solution. Any help would be appreciated
I guess you might be able to build a plugin to achieve that?
It could be confusing to redirect immediately so why not change the 404 route to redirect to home after a short timer with a corresponding message?
That could work, but I don’t know how to do that
Is there any plugin for this?
I doubt it. You could marketplace
Htaccess should not use anyway, even if there would be Apache2 fronf of Discourse — and there isn’t.
Docker makes life more complicated and I don’t know how to handle it. But you can put Nginx (or what ever server/reserve proxy) before Discourse if you want. And then such redirection should be quite trivial task. You can do something like this:
But why would you like to redirect 404s back to frontpage in the first place? If an user is looking for something and gets frontpage instead wanted or 404, it it a bit confusing. And after that same user will try again because perhaps she/he did something wrong or that site had an issue. Totally unnecessary and there is reason why every site should show error 404 instead some strange redirection.
I’m migrating my WordPress blog to Discourse. Now due to different link structure, there will be tons of 404 pages after the migration. I can’t set a redirect for each one of them manually, so I need a solution to do that automatically.
Yes, but that is not a solution. That is bad fix, nothing else. Your url structure would be still broken but you are just hiding it. And no, you can’t transfer seo value that way
Anyway — then you have a server there. Try to use it?
If you were to use a different subdomain for the Wordpress and Discourse sites you would likely be able to do this at the Wordpress server end.
It’s possible to amend page_not_found.title
(originally “Oops! That page doesn’t exist or is private.”) – it’s a shame for you that there isn’t something like page_not_found.content
that would allow you to explain the situation in detail.
That option doesn’t involve any kind of redirection, if I’m not wrong.
Whatever those links are pointing to… is it going to be migrated to Discourse? For example, if those links point to blog posts, that you are turning into topics, then you could create permalinks: Redirect old forum URLs to new Discourse URLs
You could also remap those URLs to something else. Assuming the URLs have some common formatting, you could use REGEX and the remap command to replace them:
remap [--global,--regex] FROM TO
An example on how to use the command:
discourse remap --regex "\[\/?color(=[^\]]*)*]" "" # removing "color" bbcodesc
Except that must be done on the server of WordPress if one wants to keep Google AND users happy.
5 posts were split to a new topic: How do I redirect to homepage after topic deletion?
You can handle all broken 404 pages to the home page or another page using the “Customize” feature.
Go to the section Customize > Themes > Create New Theme > name your theme ex 404 Redirect and set the Base Theme to Default.
Then create the new theme > Edit CSS/HTML. In the HTML section, create a JavaScript snippet that will handle the redirection.
Past this code.
<script type="text/discourse-plugin">
api.onPageChange((url, title) => {
// Redirect to the home page for all 404 pages
if (url.includes('/404')) {
window.location.href = '/';
}
});
</script>
Please adjust your page name according to your need. Read this redirect old url to new discourse url