Redirect http to https

How to automatically redirect all your http request to your https website ?
Simply add this 3 lines in your http VirtualHost configuration

1
2
3
RewriteEngine on
RewriteCond %{HTTPS} !^on$ [NC]
RewriteRule . https://%{HTTP_HOST}%{REQUEST_URI}  [L]

Don’t forget to activate your rewrite module

1
a2enmod rewrite

php unzip no 1024 limit

Here, a simple script to unzip a .zip file in php without the 1024 characters limitations

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
function unzip($zip, $root, $target_folder = "")
{
    $zip_file = zip_open($root . $zip);
    while ($zip = zip_read($zip_file))
    {
        $zip_object = zip_entry_name($zip);
        if (!is_dir(dirname($root . $target_folder . $zip_object)))
        {
            mkdir(dirname($root . $target_folder . $zip_object), 0777, true);
        }
        $hedef_doc = $root . $target_folder . $zip_object;
        if(substr($hedef_doc, -1) != "/")
        {
            touch($hedef_doc);
            $target_file = fopen($hedef_doc, 'w');
            $size = 0;
            while($size < zip_entry_filesize($zip))
            {
                 fwrite($target_file, zip_entry_read($zip));
                 $size += 1024;
            }
             fclose($target_file);
        }
    }
    return true;
}
 
unzip("file.zip", "./", "target_directory");

IE blocking cookies in frames

For “security” reasons (stuff related to P3P Platform for Privacy Preferences), Internet Explorer does not accept cookies for a site inside a frame. But you can force him to accept cookies by adding this in your http header

PHP:

1
header('P3P:CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"');

ASP.NET:

1
HttpContext.Current.Response.AddHeader("p3p","CP=\"IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT\"");

Django:

1
2
response = render_to_response('mytemplate.html')
response["P3P"] = 'CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"'

JSP:

1
response.addHeader("P3P","CP=\"IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT\"")