Search Unity

WebGL template - can't use index.php

Discussion in 'Web' started by tomekkie2, Aug 5, 2015.

  1. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    973
    I am getting the error:
    "\index.html does not exist"
    when try to use index.php instead of index.html.
    Is that a documentation error or there is a way to fix that?

    At the same time the documentation on the manual page here:
    http://docs.unity3d.com/Manual/webgl-templates.html says:
    "Each template folder contains an index.html or index.php"

    I guess - I didn't check - the same may happen with WebPlayer templates.

    Possibly a hack solution to that could be to add some pre-build editor script to rename .php to .html with a post-build function to rename it back, but I am hoping for some other answer.
     
    Last edited: Aug 5, 2015
  2. BytesCrafter

    BytesCrafter

    Joined:
    Apr 16, 2016
    Posts:
    8
    Note: first is upload your file to the same directory as the index.php then inside the php, you could put this. Also make sure that you extract all the files from the Release folder excluding the UnityLoader.js.

    <?php
    include dirname(__FILE__).'/index.html'; Note: index.html is the html file of your unity game/app.
    ?>

    Hope this helps, if you want tutorials like, maybe you could visit me at bytescrafter.weebly.com
     
  3. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    973
    But the issue is - if you have both index.html and index.php files inside the directory, the system priority is .html and it would use .html.
    I guess possibly you should add a .htaccess file into the directory, containing the directive
    Code (CSharp):
    1. DirectoryIndex index.php index.html
    in order to change that.

    But anyway you just can't include .html file into php without additional steps like explained here:
    http://stackoverflow.com/questions/11887429/php-include-for-html

    BTW. why dirname(__FILE__).'/index.html'; not just 'index.html'?
     
    Last edited: Feb 5, 2017
  4. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    973
    I have just checked the most recent version, 5.6 .
    It is no problem now.
    Unity now accepts both file types and I have managed to use php file as webgl template.