I have the following rules in my .htaccess file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/en-us/
Rewriterule ^(.*) /en-us/error-404/ [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
Rewriterule ^(.*) /error-404/ [L]
And it's working fine. When there are requests starts with /en-us/
, I can see the content of /en-us/error-404/
page and in all other cases I see the content of /error-404/
page. However, the status code received from the server is 200 OK
.
Is it possible to send 404 Not Found
in both cases?
CodePudding user response:
You can use if/elseif/else
conditions to use different ErrorDocument
directives: (available in Apache 2.4
)
<If "%{REQUEST_URI} =~ m#^/en-us/#">
ErrorDocument 404 /en-us/error-404/
</If>
<Else>
ErrorDocument 404 /error-404/
</Else>