diff --git a/app/views/exceptions/not_found.html.erb b/app/views/exceptions/not_found.html.erb
index b9268d34954..ca44c1d80e0 100644
--- a/app/views/exceptions/not_found.html.erb
+++ b/app/views/exceptions/not_found.html.erb
@@ -41,5 +41,11 @@
document.getElementById('google-query').value = 'site:<%= local_domain %> ' + searchValue;
return true;
}
+
+ window.onpopstate = function(event) {
+ if (!window.hasOwnProperty("Discourse")) { //check if Discourse object exists if not take care of back navigation
+ window.location = document.location;
+ }
+ };
<%- end %>