Reputation: 953
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
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