htaccess redirect for non-www both http and https

Try this rule: RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$ RewriteCond %{HTTPS}s ^on(s)| RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301] Here’s an explanation: The first condition tests if the HTTP header field Host has the required format (contains exactly one period). The second condition tests if the concatenated value of the value of the HTTPS variable (values on and off) and s … Read more

Do we need to close the response object if an error occurs while calling http.Get(url)?

General concept is that when a function (or method) has multi return values one being an error, error should be checked first and only proceed if the error is nil. Functions should return zero values for other (non-error) values if there is an error. If the function behaves differently, it should be documented. http.Get() does … Read more

HTTP Expires header values “0” and “-1”

The problem is in how invalid Expires header processed by Internet Explorer (especially older versions). IE uses Trident layout engine and WinINET API to process HTTP requests. As you may know Expires could be specified in HTTP header Expires: 0 or in meta tag <meta http-equiv=”Expires” content=”0″> In second case, Expires became part of the … Read more

Keep-alive header clarification

Where is this info kept (“this connection is between computer A and server F“)? A TCP connection is recognized by source IP and port and destination IP and port. Your OS, all intermediate session-aware devices and the server’s OS will recognize the connection by this. HTTP works with request-response: client connects to server, performs a … Read more

What should a Multipart HTTP request with multiple file inputs look like? [duplicate]

Well, note that the request contains binary data, so I’m not posting the request as such – instead, I’ve converted every non-printable-ascii character into a dot (“.”). POST /cgi-bin/qtest HTTP/1.1 Host: aram User-Agent: Mozilla/5.0 Gecko/2009042316 Firefox/3.0.10 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive Referer: http://aram/~martind/banner.htm Content-Type: multipart/form-data; boundary=2a8ae6ad-f4ad-4d9a-a92c-6d217011fe0f Content-Length: 514 … Read more

What specific use cases call for BOSH over WebSockets and long-polling? [closed]

First let me address WebSockets readiness: WebSockets implementation of the Hixie-76 protocol are shipped and enabled by default in Chrome, Safari and iOS (iPhone and iPad). The Hixie-76 protocol is also shipped but disabled by default in Firefox 4 and Opera 11. The web-socket-js project is a Flash shim/polyfill that adds WebSocket (Hixie-76) support to … Read more