.html extension leading to wrong 404 page | Community
Skip to main content
milind_bachani
Employee
Mar 21, 2022 6:55 AM UTC
Solved

.html extension leading to wrong 404 page

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.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
milind_bachani
milind_bachaniAccepted solution
Employee
Mar 21, 2022 8:25 AM UTC

@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 ?

2 replies

DEBAL_DAS
New Participant
Mar 21, 2022 8:20 AM UTC

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. 

 

Translate
milind_bachani
milind_bachaniAuthorAccepted solution
Employee
Mar 21, 2022 8:25 AM UTC

@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 ?

Translate