ErrorDocument 404 404 php is not working in htaccess file in PHP

0 votes

This is the Content of my .htaccess file is:

ErrorDocument 404 /404.php 

It is in the root directory and the 404.php file is also there. The problem is that when I misspelled the URL, 404.php it doesn't open. Instead, I am getting this message:

Not Found

The requested URL /mywebsite/ites.php was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

But when I tried ErrorDocument 404 google.com, it worked. Can Someone please help me with this?

Jun 21, 2022 in PHP by narikkadan
• 63,600 points
937 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes
The /404.php path will not always be the absolute path to your htdocs folder root but instead the root of your filesystem. This may be, based on your configuration. To do this you have to find out the absolute path and set it accordingly.
answered Jun 23, 2022 by Kithuzzz
• 38,000 points

edited Mar 5
0 votes

Add debugging code to your 404.php file to confirm that it is being executed or not. 

ex..

<?php
// 404.php
echo "Custom 404 page is working!";
// Rest of your 404 page content
?>
Also check 404.php file has the correct permissions

answered Sep 30, 2023 by rahul
• 110 points

edited Mar 5

Related Questions In PHP

0 votes
0 answers

PHP is not recognized as an internal or external command in command prompt

I am getting this error when I ...READ MORE

May 7, 2022 in PHP by narikkadan
• 63,600 points
2,275 views
0 votes
0 answers

How to open a file named index.php which is in htdocs/project1 folder in xampp?

I have a folder named project1 in ...READ MORE

May 29, 2022 in PHP by Kichu
• 19,040 points
3,193 views
0 votes
0 answers
0 votes
0 answers

Why is PHP session_destroy() not working?

Why is session_destroy() not working? Is there any other way ...READ MORE

Jun 12, 2022 in PHP by narikkadan
• 63,600 points
1,515 views
0 votes
0 answers

Mail is not sending in php

My code to send mail from PHP: ...READ MORE

Jul 28, 2022 in PHP by Kithuzzz
• 38,000 points
918 views
0 votes
1 answer

Generator URL Friendly SEO PHP with .htaccess

Options +FollowSymLinks -MultiViews RewriteEngine on RewriteBase / # skip all ...READ MORE

answered Feb 14, 2022 in Others by narikkadan
• 63,600 points
4,598 views
0 votes
1 answer

mod_rewrite seo friendly url passed as parameter only works with prefix on url

RewriteEngine On RewriteRule ^content/get_content.php\?url\=seo-friendly-url$ /content/seo-friendly-url [L] try this code ...READ MORE

answered Feb 24, 2022 in Others by narikkadan
• 63,600 points
1,863 views
0 votes
1 answer

mod_rewrite seo friendly url passed as parameter only works with prefix on url

RewriteEngine On RewriteRule ^content/get_content.php\?url\=seo-friendly-url$ /content/seo-friendly-url [L] try this code ...READ MORE

answered Feb 27, 2022 in Others by narikkadan
• 63,600 points
776 views
0 votes
1 answer

Using .htaccsess Generator URL Friendly SEO PHP

Options +FollowSymLinks -MultiViews RewriteEngine on RewriteBase / # skip all ...READ MORE

answered Feb 27, 2022 in Others by narikkadan
• 63,600 points
690 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP