no directory exist

diabolo

Community Advocate
Community Support
Messages
1,682
Reaction score
32
Points
48
I'm not sure how I would display a specific custom error page for
dir/non_existent_dir_1

I know to display a regular 404 error page would be using cPanel, but i want this to be a custom one different from just a regular 404.

Like it would say, this directory could not be found, please go to home
instead of the regular, this page is missing

I was thinking maybe a .htaccess?
 

xav0989

Community Public Relation
Community Support
Messages
4,467
Reaction score
95
Points
0
I don't know of any way of doing this through .htaccess. However, you could use this snippet I made to check if the missing page is a directory of a page, and then output a different html depending.
PHP:
<?php
if (is_dir($_SERVER['PHP_SELF'])) {
    //It is a directory, output directory only 404 page

    //code here
    exit;
} else {
    //It is a page, output page only 404 page

    //code here
    exit;
}
?>
 
Last edited:

marshian

New Member
Messages
526
Reaction score
9
Points
0
It's done with .htaccess
Add this to the .htaccess file in the directory you want to change:
Code:
ErrorDocument 404 file.php
You can replace 404 with other status codes and of course change file.php into the url for the error document.
 

diabolo

Community Advocate
Community Support
Messages
1,682
Reaction score
32
Points
48
thank you, i will go try that and see how it works
 
Top