Issue
I want URLs with a specific path to return an automatic 200 status response. I have tried the below, but get a an error when I try to start Apache:
First error: RewriteCond: bad flag delimiters
RewriteEngine On
RewriteCond %{THE_REQUEST} GET /the_url/
RewriteRule ^ - [R=200]
If I remove the path part then I do not get the error:
RewriteEngine On
RewriteCond %{THE_REQUEST} GET
RewriteRule ^ - [R=200]
But, of course, I need a way to include the path requirement.
Another error is that, even when the server does return a status 200 above (verified in Developer Tools), then the page still displays an error message: "OK The server encountered an internal error or misconfiguration and was unable to complete your request...." Is it not really returning a status 200? Or is it, but this is just what the default HTML page is when nothing is provided by the server?
Solution
The following did the trick. From https://httpd.apache.org/docs/2.4/custom-error.html
Enable the mod_rewrite module
LoadModule rewrite_module modules/mod_rewrite.so
and then add the following to your virtual host.
ErrorDocument 200 "ok"
RewriteEngine On
RewriteRule "/the_url/" - [R=200]
EDIT:
My original answer has been edited so much by someone else that it is no longer quite the same. I'll leave the edited answer (above), but I did not have to enable the mod_rewrite module. Some Linux distributions come with this by default or your host might have provided it as their default starting point. I added the three lines to httpd.conf.
Answered By - user984003