Search code examples
phpapache.htaccess

.htaccess works fine in local machine but not in server


I am developing a website in core PHP and I want the pages to automatically redirect to my custom page (404.php) when someone enters invalid URL after the domain name. For example, I have a URL like www.abcdefg.com/abcd.php and if someone enters www.abcdefg.com/abzzcd.php, instead of showing the 404 error, I want to display the custom message.

It works fine in the local machine (XAMPP - localhost). Website is hosted in HostDime.

​<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /sunday/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /sunday/404.php [L]
</IfModule>

Solution

  • thanks for your suggestions and help. I got the solution by myself.

    ErrorDocument 404 /admin/production/page_403.html
    

    Simply added this at the end of my code and it works perfectly !

    Thank you.