DanMad
DanMad

Reputation: 1755

.htaccess issue when including custom 404 error page

This is my first time using .htaccess and currently my .htaccess file is redirecting to my custom 404 page. This is being handled with the following line in my .htaccess file:

ErrorDocument 404 /404.html

On top of this, I need to rewrite a few urls so that /addition/ points to /includes/addition.html (this is one example). So I add the following:

RewriteEngine On
RewriteRule /addition/ /includes/addition.html

But this then serves me a 500 error when Is hold be getting 404 error. On top of this, when I point to mysite.com/addition/ the browser isn't fetching addition.html from my includes folder.

Would someone please explain to me how to have these two rules working without effecting the other, and correct my secondary rewrite rule?

Danke.

Upvotes: 1

Views: 95

Answers (1)

anubhava
anubhava

Reputation: 786241

Have it this way in your site root .htaccess:

ErrorDocument 404 /404.html

RewriteEngine On
RewriteRule ^/?([a-z]+)/?$ /includes/$1.html [L,NC]

Upvotes: 1

Related Questions