Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

.html extension leading to wrong 404 page

Avatar

Community Advisor

I have a scenario where if I access:
<domain>/blah-blah (non existing page) redirects me to correct 404 page.


BUT, if I access :
<domain>/blah-blah.html (non existing page with .html extension) redirects me to generic 404 page.

 

Expectation :
Both the scenarios should be redirecting me to custom 404 page (same as scenario1).


Open to suggestions, thanks in advance.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

@DEBAL_DAS , I was thinking in the same direction by adding :

RewriteRule ^/(.*).html$ /$1 [R=301,NE,L]

which strips out the html by default from all accessed URLs, but is it the only way to achieve it ?

View solution in original post

2 Replies

Avatar

Community Advisor

Are you accessing your website pages without .html extension? if yes then if we add rewrite rule at webserver when you request <domain>/blah-blah.html, it removes .html and redirects you to correct(same) 404 page.

 

We do have this behavior. 

 

Avatar

Correct answer by
Community Advisor

@DEBAL_DAS , I was thinking in the same direction by adding :

RewriteRule ^/(.*).html$ /$1 [R=301,NE,L]

which strips out the html by default from all accessed URLs, but is it the only way to achieve it ?