John
John

Reputation: 13759

How to enable $_SERVER['HTTP_IF_NONE_MATCH'] in PHP?

Both the local testing and live servers the PHP $_SERVER['HTTP_IF_NONE_MATCH'] variable isn't set. How do I enable $_SERVER['HTTP_IF_NONE_MATCH'] with Apache or PHP or trigger it in an HTTP request? The live server is a shared hosting account so please no just blindly edit the httpd.conf responses.

Upvotes: 0

Views: 809

Answers (3)

danopz
danopz

Reputation: 3408

You should send an If-None-Match header to your endpoint. If so the HTTP_IF_NONE_MATCH variable should contain the value of the If-None-Match header.

curl http://my/endpoint --header 'If-None-Match: "my-custom-etag-value"'

Upvotes: 0

Ali Gajani
Ali Gajani

Reputation: 15091

If someone needs this for Nginx too, you can put this in your nginx.conf.

fastcgi_param HTTP_IF_NONE_MATCH $http_if_none_match;

Upvotes: 0

Javier Arias
Javier Arias

Reputation: 2488

Just include it in a .htaccess file within your ROOT:

RewriteEngine on
RewriteRule .* - [E=HTTP_IF_NONE_MATCH:%{HTTP:If-None-Match}]

Upvotes: 1

Related Questions