Page 1 of 1

how can i Redirect 404 page to special page?

Posted: Thu Apr 21, 2011 2:17 am
by shetab24
hello all
this is my first post in here :)
i have changed my shop from something to OC.
all my indexed link routing to 404 page. page not found.
how can i Redirect 404 page to special page like homepage or whatever page in my host by using htaccess?
this code does'nt work for me.

Code: Select all

ErrorDocument 404 /index.php

Re: how can i Redirect 404 page to special page?

Posted: Thu Apr 21, 2011 9:38 am
by justinv
OpenCart handles all pages, even those where the request is not found with this controller here:

catalog/controller/error/not_found.php

Re: how can i Redirect 404 page to special page?

Posted: Thu Apr 21, 2011 3:43 pm
by shetab24
justinv wrote:OpenCart handles all pages, even those where the request is not found with this controller here:

catalog/controller/error/not_found.php
okey
in fact is there any way to steer the default page (not_found.php) to home page(index.php) or anywhere else in the host?

Re: how can i Redirect 404 page to special page?

Posted: Fri Apr 22, 2011 1:07 pm
by justinv
In the controller file that I mentioned you would need to put this:

Code: Select all

$this->redirect('http://www.yoursite.com/index.php");
before the line that starts with something like this:

Code: Select all

$this->render(........)

Re: how can i Redirect 404 page to special page?

Posted: Thu Mar 21, 2013 4:46 am
by seoadsem
It works, but in this case you won't be able anymore to change the currency. It will send you to a blank page.

Re: how can i Redirect 404 page to special page?

Posted: Sat Mar 30, 2013 11:54 am
by butte
The point of 404 and other standard error pages is to show the problem, not hide it. Apache has a small standard set of them. Your server may allow you to use your own custom error pages, but the general response you will face (from support and from the experienced) if you try to nullify error pages is amusement. You might as well ask how you can hide your license plates at the wrong times, or how your ambulance service can defeat all of the emergency lighting and siren switches. With custom error pages you can provide a link to where you would like people to end up (or restart), and you can tailor what they're shown about the error. Servers' own customized error pages often advertize their own services and rates ("Surprise, this is a booboo page, the website you're visiting just blew it, but, lo, we host it and you, too, can sign up right here!"). Yours doesn't have to attempt to do that.

Re: how can i Redirect 404 page to special page?

Posted: Wed Sep 13, 2017 5:57 pm
by hassanalishah
justinv wrote:
Fri Apr 22, 2011 1:07 pm
In the controller file that I mentioned you would need to put this:

Code: Select all

$this->redirect('http://www.yoursite.com/index.php");
before the line that starts with something like this:

Code: Select all

$this->render(........)
I tried this but i am getting below error:

arse error: syntax error, unexpected ''https://www.q-depot.com/index' (T_ENCAPSED_AND_WHITESPACE) in /home/qdepot55/public_html/catalog/controller/error/not_found.php on line 68

Could you please assist on this? Thanks!