I'm assuming that index.html contains an include similar to the snippet below (assumption is that we're doing a client-side pull of this javascript).
<script type="text/JavaScript" src="getjavascript.php?id=index" />
If your intent is to hide secrets within the javascript file, there is no way of stopping a user from retrieving the contents. They can trivially use developer tools to view the contents. Furthermore, because the browser needs to download the file, there's not really a way to distinguish between a user accessing directly versus a browser retrieving this file.
If your intent is to obfuscate the fact that your server is using PHP, you can use mod_rewrite to remove the extension.
Server side includes are a different story and modifications to .htaccess or moving this file outside of your webroot directory would work.