I have edited my 404.html page and want to use it for pages not found on my site.
I have added the following code to the bottom of my main .htaccess file:
ErrorDocument 404 /404.html
When I test it the page that comes up is "Page was not found" and not my 404.html page.
Does anyone know what else I need to do to view my custom 404.html page?
Thanks in advance.
|
Can anyone help me with this? |
1) The requests like http://your-domain.com/path-to-dolphin/unknownurl1 are routed to profiles, if profile isn't found then custom page not found url is generated.
2) The requests like http://your-domain.com/path-to-dolphin/unknownurl1/unknownurl1 should be regular 404 (page not found) error, which can be changed via .htaccess file for example, like you did.
Back to 1), if you want to change this page and all pages inside Dolphin when page not found (for example modules routing errors) you can replace the following code in inc/classes/BxDolTemplate.php file:
function displayPageNotFound ()
{
$sTitle = _t('_sys_request_page_not_found_cpt');
$GLOBALS['_page'] = array(
'name_index' => 0,
'header' => $sTitle,
'header_text' => $sTitle
);
$GLOBALS['_page_cont'][0]['page_main_code'] = MsgBox($sTitle);
header("HTTP/1.0 404 Not Found");
PageCode();
exit;
}
to this one:
function displayPageNotFound ()
{
header("HTTP/1.0 404 Not Found");
readfile(BX_DIRECTORY_PATH_ROOT . '404.html');
exit;
}
Rules → http://www.boonex.com/terms |
Brilliant, thanks so much for your response, it's worked perfectly. |
I replaced the code with your code and I mentioned "index.php" in place of "404.html", then it shows something, please have a look...
not installed. \n"; if ( file_exists( "install/index.php" ) ) { echo "Please, wait. Redirecting you to installation form... \n"; echo "\n"; } exit; } require_once( 'inc/header.inc.php' ); require_once( BX_DIRECTORY_PATH_INC . 'design.inc.php' ); require_once( BX_DIRECTORY_PATH_INC . 'admin.inc.php' ); require_once( BX_DIRECTORY_PATH_INC . 'db.inc.php' ); require_once( BX_DIRECTORY_PATH_INC . 'profiles.inc.php' ); require_once( BX_DIRECTORY_PATH_INC . 'prof.inc.php' ); require_once( BX_DIRECTORY_PATH_INC . 'utils.inc.php' ); require_once( BX_DIRECTORY_PATH_INC . 'membership_levels.inc.php' ); bx_import('BxDolPageView'); bx_import('BxDolProfileFields'); bx_import('BxTemplFormView'); bx_import('BxTemplVotingView'); bx_import("BxTemplIndexPageView"); //-- registration by invitation only --//; if (!empty($_GET['idFriend']) && (int)$_GET['idFriend'] && getParam('reg_by_inv_only') == 'on') { setcookie('idFriend', (int)$_GET['idFriend'], 0, '/'); } check_logged(); $_page['name_index'] = 1; $oSysTemplate->setPageTitle($site['title']); $oSysTemplate->setPageDescription(getParam("MetaDescription")); $oSysTemplate->setPageMainBoxTitle($site['title']); $oSysTemplate->addPageKeywords(getParam("MetaKeyWords")); $oSysTemplate->addCss(array('index.css')); $oIPV = new BxTemplIndexPageView(); $_ni = $_page['name_index']; $_page_cont[$_ni]['page_main_code'] = $oIPV -> getCode(); PageCode();
What should I do in that case...?
Thanks
1) The requests like http://your-domain.com/path-to-dolphin/unknownurl1 are routed to profiles, if profile isn't found then custom page not found url is generated.
2) The requests like http://your-domain.com/path-to-dolphin/unknownurl1/unknownurl1 should be regular 404 (page not found) error, which can be changed via .htaccess file for example, like you did.
Back to 1), if you want to change this page and all pages inside Dolphin when page not found (for example modules routing errors) you can replace the following code in inc/classes/BxDolTemplate.php file:
function displayPageNotFound ()
{
$sTitle = _t('_sys_request_page_not_found_cpt');
$GLOBALS['_page'] = array(
'name_index' => 0,
'header' => $sTitle,
'header_text' => $sTitle
);
$GLOBALS['_page_cont'][0]['page_main_code'] = MsgBox($sTitle);
header("HTTP/1.0 404 Not Found");
PageCode();
exit;
}
to this one:
function displayPageNotFound ()
{
header("HTTP/1.0 404 Not Found");
readfile(BX_DIRECTORY_PATH_ROOT . '404.html');
exit;
}
|
This solution works with html files only, not php.
I replaced the code with your code and I mentioned "index.php" in place of "404.html", then it shows something, please have a look...
Rules → http://www.boonex.com/terms |
Many Thanks for the solution Alex, I tried it on html page and it worked, but I have one more question, if I'll create an html page then how will I get the functionality which is in PHP. I want the same functionality which is on Index Page (all the menu links and other things should work as it is working in live site (php pages)). Please visit @ www.helpmyindia.com
This solution works with html files only, not php.
I replaced the code with your code and I mentioned "index.php" in place of "404.html", then it shows something, please have a look...
|
Use an html redirect; first send it to the 404 page that then redirects back to your home page. In the head section of the 404.html put:
<meta http-equiv="Refresh"; url=http://mysite.tld/index.php">
It does add a bit of overhead because you first go to 404 then index but it is slight. There are also javascript redirection solutions.
Geeks, making the world a better place |
I tried the below mentioned code, but it is not redirecting from 404.html to another page, it stick to 404.html page only.
I tried <meta http-equiv="Refresh"; url="http://mysitename/index.php"> in the head on 404.html page.
Use an html redirect; first send it to the 404 page that then redirects back to your home page. In the head section of the 404.html put:
<meta http-equiv="Refresh"; url=http://mysite.tld/index.php">
It does add a bit of overhead because you first go to 404 then index but it is slight. There are also javascript redirection solutions.
|
My apologies, I did not do the HTML redirect correctly; try the code below and see if it works.
<meta http-equiv="refresh" content="0; url=http://mysite.tld/">
The zero is the time to wait before moving to the new page in seconds; you can increase this if you want to display a message for a few seconds before taking them to the new page.
Geeks, making the world a better place |
Thanks for the update, now it's working however yesterday I tried with javascript and it works fine with that also...
My apologies, I did not do the HTML redirect correctly; try the code below and see if it works.
<meta http-equiv="refresh" content="0; url=http://mysite.tld/">
The zero is the time to wait before moving to the new page in seconds; you can increase this if you want to display a message for a few seconds before taking them to the new page.
|