How to place a chrome extension?

I need to host my chrome extension on my shared hosting with PHP.

I know that my server should use the appropriate HTTP headers: code.google.com/chrome/extensions/hosting.html

But how to configure my server to send these headers depending on the .crx file?

+5
source share
2 answers

If you use shared hosting and cannot change the server configuration, use PHP:

<?php
$file = 'extension.crx';

if (file_exists($file)) {
    header('Content-Description: File Transfer');
    header('Content-Type: application/x-chrome-extension');
    header('Content-Disposition: attachment; filename='.basename($file));
    header('Content-Transfer-Encoding: binary');
    header('Expires: 0');
    header('Cache-Control: must-revalidate');
    header('Pragma: public');
    header('Content-Length: ' . filesize($file));
    ob_clean();
    flush();
    readfile($file);
    exit;
}
?>

source

This will cause the file (specified by the variable $file) to be loaded using custom headers.

+6
source

I do not know which web server you are using, but for Apache you can do the following:

  • vi /path/to/your/httpd/conf/mime.types
  • : application/x-chrome-extension crx
  • -: killall -HUP httpd

.htaccess:

AddType application/x-chrome-extension crx

!

+1

All Articles