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

Can I use the HTTP range header to load partial files “on purpose”?

You are right, the link which you posted in the comment would be probably the best approach. As your question sounded interesting i tried it out. You probably did it also, but here is an snippet (for other, that may come looking) var xmlhttp = new XMLHttpRequest();“GET”,”data.dat”,false); xmlhttp.setRequestHeader(“Range”, “bytes=100-200”); xmlhttp.send();; //–> returns only … 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


You should use the proper HTTP verb according to what you require from your web service. When dealing with a Collection URI like: GET: List the members of the collection, complete with their member URIs for further navigation. For example, list all the cars for sale. PUT: Meaning defined as “replace the entire collection … Read more

Checking if a URL is broken in Javascript

I’d recommend to use jQuery for correct cross-browser ajax requests: function UrlExists(url, cb){ jQuery.ajax({ url: url, dataType: ‘text’, type: ‘GET’, complete: function(xhr){ if(typeof cb === ‘function’) cb.apply(this, [xhr.status]); } }); } Usage: UrlExists(‘/path/’, function(status){ if(status === 200){ // file was found } else if(status === 404){ // 404 not found } });

PHP, pass array through POST

Edit If you are asking about security, see my addendum at the bottom Edit PHP has a serialize function provided for this specific purpose. Pass it an array, and it will give you a string representation of it. When you want to convert it back to an array, you just use the unserialize function. $data … Read more

Default redirect for Error 404

This is how you configure a custom 404 error page for both ASP.NET and non-ASP.NET requests: <configuration> <system.web> <compilation targetFramework=”4.0″ /> <customErrors mode=”On” redirectMode=”ResponseRewrite”> <error statusCode=”404″ redirect=”http404.aspx” /> </customErrors> </system.web> <system.webServer> <httpErrors errorMode=”Custom”> <remove statusCode=”404″/> <error statusCode=”404″ path=”/http404.aspx” responseMode=”ExecuteURL”/> </httpErrors> </system.webServer> </configuration> As others already pointed out, you should not use an HTTP redirection to … Read more