1

I wanted to replace the .html extensions with just nothing in apache.

Eg. DNS/coffee.html to be DNS/coffee. I found myself this code.

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^([^/]+)/?$ $1.html [L]
</IfModule>

It does the job I wanted, but it doesn't.

It seems to not like 404.html for errors. Everytime I open a page that doesn't exist, it doesn't give me the 404 page anymore, but a 500 internal server error message:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at EMAIL to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.

Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request. Apache/2.4.41 (Ubuntu) Server at URL Port 443

I don't know what I am suposed to do, google doesn't give me wise answers, only things like “how to redirect a page to 404.html” or “how to make every link that doesn't go to this DNS reditect to 404 page.”

Here is the code for .htaccess.

# ------------------Error Pages--------------------
# 404 NOT FOUND
ErrorDocument 404 /errors/404.html
# -----------------Rem .html and .htm extensions---
 
<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^([^/]+)/?$ $1.html [L]
</IfModule>

0

You must log in to answer this question.