First post. Newly created account. Hope this is the right forum. Do not want to duplicate post.
ErrorDocument not working in .htaccces file
Do not have wordpress or any other apps installed except what was installed when the website was created.
Trying to create a custom ErrorDocument in PHP.
This is the errordocument code in my .htaccess file (only one line is NOT commented out at a time). Currently it is:
###ErrorDocument 404 "From .htaccess - This is a custom 404 error page done with ErrorDocument in .htaccess"
###ErrorDocument 404 /404.html
ErrorDocument 404 /404.php
The literal, and the php will not work (will display the HTML 404 error page)
The html works right (will display the text from the html file)
If I execute the php version as a url in the browser it will display the error message - so it is not the code. https://domainfwd.000webhostapp.com/404.php
So, my question is — How do I get the php version to work?
This is the code for 404.php
<?php
?>
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<p>From 404.php - This is a custom 404 error page done with ErrorDocument in .htaccess</p>
</body>
</html>
this is the code for 404.html
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<p>From 404.html - This is a custom 404 error page done with ErrorDocument in .htaccess</p>
</body>
</html>
tried
ErrorDocument 404 "From .htaccess - This is a custom 404 error page done with ErrorDocument in .htaccess"
but did not work. also displays the 404.html code
I did that (see top of first post)
ErrorDocument 404 /404.php
The trouble is that it will not execute the php file. It uses the html file (404.html).
in the first post i show the code for the .htaccess, 404.html, and 404.php along with urls to try.
So, my question is — How do I get the php version to work?
When it comes to PHP scripts, the .htaccess uses the root of your filesystem (which is definitely not the one from /public_html). To avoid paths complications, please input the coded the way I provided it
tried the code above (copy and paste) and it still goes to the 404.html instead of 404.php. as an example this will not be found and will display the custom error message from HTML 404 error page - not the php page. https://domainfwd.000webhostapp.com/waileqb.html
The main .htaccess from /public_html redirects all traffic to /public_html/zyro. If we change the Zyro code from it, the whole website will not render anymore.
It is pretty difficult to add a ErrorPage directive because of how Zyro publishes the website. The only way I have found to do it is to replace the entire .htaccess from /public_html/zyro with the proper directives and move all 404 files to /public_html/zyro.
However:
This will remove the protection of the other directories from within /zyro folder
The settings will be lost next time you publish the website from Zyro Builder.