desbest Posted April 24, 2019 Share Posted April 24, 2019 My error pages do not show on my website. [see here] My web browser Firefox shows this error Quote The page isn't redirecting properly An error occurred during a connection to hostingz.org. This problem can sometimes be caused by disabling or refusing to accept cookies. I have no PHP on the error404.php template. What is going on, and how do I fix it? Link to comment Share on other sites More sharing options...
louisstephens Posted April 24, 2019 Share Posted April 24, 2019 When I go to the link provided, I currently see a "sample swap feedback" image and sidebar without any errors. What is supposed to be displaying? Link to comment Share on other sites More sharing options...
desbest Posted April 24, 2019 Author Share Posted April 24, 2019 No that's not the page that should be displaying. This page should be displaying instead. Link to comment Share on other sites More sharing options...
dragan Posted April 24, 2019 Share Posted April 24, 2019 Did it used to work previously? The response header for a non-existing site shows HTTP 302. It means there's something wrong with your setup. Check the .htaccess file first. Maybe you have set up your own redirects, either manually in .htaccess, or with a module (e.g. this one) inside PW admin. Or maybe even a hook. Check the logs if you find something suspicious. https://processwire.com/docs/start/install/troubleshooting/ Link to comment Share on other sites More sharing options...
desbest Posted April 24, 2019 Author Share Posted April 24, 2019 I've made my own redirect template for redirecting url's like http://hostingz.org/indicho I think this redirect template is conflicting with the error 404 page. <?php function bot_detected() { return ( isset($_SERVER['HTTP_USER_AGENT']) && preg_match('/bot|crawl|slurp|spider/i', $_SERVER['HTTP_USER_AGENT']) ); } if (bot_detected() === true){ //echo "is a bot"; } else { //echo "not a bot"; $hitcount = $page->views; $newhitcount = $page->views +1; //add 1 to the view counter $daview = $pages->get($page->id); $daview->of(false); $daview->views = $newhitcount; $daview->save(); //save the higher value onto the link page } $session->redirect($page->daurl); //redirect to link ?> and there's _init.php <?php $pages->addHookBefore('Page::path', function($event) { $page = $event->object; if($page->template == 'post') {// template used by 'post-a' // ensure that pages with template 'post' live off the root rather than '/posts/' $event->replace = true; $event->return = "/$page->name/"; } }); ?> Link to comment Share on other sites More sharing options...
BitPoet Posted April 25, 2019 Share Posted April 25, 2019 11 hours ago, desbest said: $session->redirect($page->daurl); I think that could be the problem. The redirect for the 404 page comes back without a value in the location header. It might be as easy as checking whether the current page id equals $config->http404PageID to decide whether to redirect or not. Link to comment Share on other sites More sharing options...
desbest Posted April 25, 2019 Author Share Posted April 25, 2019 Hello I've updated the code to if ($page->id != $config->http404PageID) { $session->redirect($page->daurl); } //redirect to link and it still doesn't work Link to comment Share on other sites More sharing options...
louisstephens Posted April 25, 2019 Share Posted April 25, 2019 Just curious, is "daurl" a field you have defined in processwire? If not, i think you might need to use $page->url for the actual url of the page Link to comment Share on other sites More sharing options...
desbest Posted April 26, 2019 Author Share Posted April 26, 2019 "daurl" is a field I've defined in processwire myself Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now