2

I am using a virtual hosting to host my php site on apache. For example I want to set http://www.example.com/content/ only this specific directory force to response HTTP/1.0 because I have a application need the content-length in the response header. I've tried to add a .htaccess file in the "content" directory but it seems not work. There are just two lines in the file:

SetEnv downgrade-1.0 1
SetEnv force-response-1.0 1

Moreover, is there any method to check the variable have changed? I've used phpinfo() to check but it said that still using HTTP/1.1. What's wrong with my .htaccess file?

Expected result is whatever HTTP/1.0 or 1.1 request sent to server, the server will force to response HTTP/1.0 with the Content-Length in the HTTP header.

Thank you.

4
  • Is AllowOverride enabled for this location? Commented Dec 20, 2015 at 9:48
  • @Gordon I've tried to add Deny From All in the .htaccess, it works, all files in that directory return Error 403 Forbidden. It should be enabled. Commented Dec 20, 2015 at 10:10
  • @anubhava Yes, I used phpinfo in that directory it said SERVER_PROTOCOL HTTP/1.1. Moreoever, I've checked the http header response from server, the Content-Length is still missing, it still using chunked transfer encoding. Commented Dec 20, 2015 at 10:20
  • Did you find a solution to this? I'm running into the same issue. However, maybe 1 in 20 or 30 of my (all identical) requests will return a response with a content-length header and not chunked. Commented Dec 9, 2016 at 16:39

1 Answer 1

2

These directives do work together in your /content/.htaccess:

SetEnv downgrade-1.0 1
SetEnv force-response-1.0 1

This forces an HTTP/1.0 response to clients making an HTTP/1.0 request. Some HTTP/1.0 clients may not behave correctly when given an HTTP/1.1 response, and this can be used to interoperate with them.

Reference

To test use command line curl to verify headers instead of phpinfo():

curl -kI -A "Chrome" -L 'localhost/content/'
HTTP/1.0 200 OK
Date: Sun, 20 Dec 2015 14:52:50 GMT
Server: Apache/2.4.12 (Unix) PHP/5.3.29 mod_wsgi/3.5 Python/2.7.9 OpenSSL/1.0.1j
X-Powered-By: PHP/5.3.29
Connection: close
Content-Type: text/html
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.