我需要在我的PHP共享主机上托管我的Chrome扩展。如何托管Chrome扩展?
我知道我的服务器必须使用占有的HTTP头:code.google.com/chrome/extensions/hosting.html
但是,如何设置我的服务器在发送成瘾这些标头.crx档案?
我需要在我的PHP共享主机上托管我的Chrome扩展。如何托管Chrome扩展?
我知道我的服务器必须使用占有的HTTP头:code.google.com/chrome/extensions/hosting.html
但是,如何设置我的服务器在发送成瘾这些标头.crx档案?
如果你是一个共享的主机,并且不能更改服务器的配置,使用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;
}
?>
这将迫使文件($file
变量指定)下载与定制的头。
我不知道什么是您使用的网络服务器,但对于Apache的,你可以做到以下几点:
/path/to/your/httpd/conf/mime.types
application/x-chrome-extension crx
在文件killall -HUP httpd
或者你可以尝试加入这一行到您的.htaccess
文件:
AddType application/x-chrome-extension crx
它应该工作!
谢谢@Konard,这非常有帮助。 – zur4ik
从技术角度来看,这是正确的,但在新版Chrome浏览器中无法使用:https://support.google.com/chrome_webstore/answer/2664769 – bfncs