0

i would like to know if it is possible to send a 200 status with a page content without passing by a status 30x ?

exemple or rewrite condition:

RewriteCond %{HTTP_USER_AGENT} ^-?$
RewriteCond %{REQUEST_URI} !errors\/noua\.htm
RewriteRule (.*) /errors/noua.htm

in this case i would like to display noua.htm directly with a 200 status (without doing a 301 redirect to noua.htm)

Thanks

2 Answers 2

1

You almost have it already

https://httpd.apache.org/docs/2.4/rewrite/flags.html

You are missing a P flag

RewriteCond %{HTTP_USER_AGENT} ^-?$
RewriteCond %{REQUEST_URI} !errors\/noua\.htm
RewriteRule (.*) /errors/noua.htm [P]
0

Thanks it worked !

I add more info cause it was in https, so the rewrite rule was returning an 500 error due to ssl proxy disabled

I had to add SSLProxyEngine On in the virtual host to have this answer fully work in https

i also noticed it has to be put in the virtual host desired, if it is added in global conf this parameters will not be shared:

example:

this works

<VirtualHost *:443>
ServerName example.domaine.com
DocumentRoot /var/www/example/
SSLProxyEngine On
RewriteCond %{HTTP_USER_AGENT} ^-?$
RewriteCond %{REQUEST_URI} !errors\/noua\.htm
RewriteRule (.*) /errors/noua.htm [P]
...
</VirtualHost>

<VirtualHost *:443>
SSLEngine on
...
</VirtualHost>

this wont works

<VirtualHost *:443>
ServerName example.domaine.com
DocumentRoot /var/www/example/
RewriteCond %{HTTP_USER_AGENT} ^-?$
RewriteCond %{REQUEST_URI} !errors\/noua\.htm
RewriteRule (.*) /errors/noua.htm [P]
...
</VirtualHost>

<VirtualHost *:443>
SSLEngine on
SSLProxyEngine On
...
</VirtualHost>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .