schenker
schenker

Reputation: 953

how do i show 404 error page without showing the error page's url?

when my users type a non-existent page such as

www.example.com\wrongurl.html

I want users to see 404 error page. But the URL should not change.

I have tried the following but doesn't work.

ErrorDocument 404 http://www.example.com/404.html

RewriteEngine On
RewriteRule 404/ http://www.example/404.html [NC]

How can i do this?

Upvotes: 2

Views: 803

Answers (1)

Amit Verma
Amit Verma

Reputation: 41209

Try the following rules :

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^ /404.html [L,NC]

This internally redirects a request for non-existing file/directory to 404.html page.

Upvotes: 2

Related Questions