0

Hi i have my htaccess with this:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ $1.htm [L]

ErrorDocument 404 /404.htm

if i erase the first 4 lines, the other piece of code (which redirects de 404 page when there's a page not found) does not work anymore.

Any ideas? I also want that when it redirects to 404.htm, it does not show on the url box, this url

http://www.mypage.com/404.htm

i want to show this

http://www.mypage.com/fail/search-by-the-user

for example.

1 Answer 1

1

Try following .htaccess

RewriteBase /
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ /$1.html

ErrorDocument 404 /404.html

NOTE: if you are working at localhost then please mention proper RewriteBase

Sign up to request clarification or add additional context in comments.

8 Comments

first problem solved, do you know a solution for the second one?
@Nick, not getting your second problem, please mention it clearly
if you go to: google.com/dhfjsdfsdjfsd the error loads on that page, it does not redirect to a page called "404" or "not-found". but in my page, it redirects to "404.htm" and i don't want that to be seen
@Nick, this working is working with ErrorDocument that mention at last in .htaccess. and it doesn't redirect, just output 404 document
@Nick, Don't use full path into .htaccess, use full path of CSS file into your 404.htm
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.