SlapOS Home SlapOS

    Web Runner configure public directory

    • Last Update:2016-11-10
    • Version:001
    • Language:en

    Configure Access to your Public directory

    Each webrunner provides a public directory which is useful to develop and deploy your HTML5 applications (read more about this public directory here).

    This directory is served by an apache2 web server. The default configuration allows you to extend it with your own rules. To do so, please create a .htaccess file at the root of the public directory.

    You can read more about the configuration of an apache2 webserver there :  http://httpd.apache.org/docs/current/en/howto/htaccess.html

    Here is an example of  a .htaccess file that you can use in your own webrunner :

    ############################################################
    # Search for index.html and serve it as default page
    DirectoryIndex index.html index.htm


    ############################################################
    # Disable directory browsing. Useful if your directory
    # doesn't contain a DirectoryIndex
    Options All -Indexes


    ############################################################
    # Allow to target your project folder without entering its
    # name in the URL.
    # For example, if your project is in the subfolder 
    # /myproject , you can just access it throught /public/,
    # instead of /public/myproject/
    # However, in this case you will have to specifically
    # precise "index.html" in you requested URL.
    RewriteEngine on
    RewriteBase /
    # These lines allow you to still access to the other
    # subfolders in your public directory
    RewriteCond %{REQUEST_URI} !^/public/myproject/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    # Rewrite all these requests to insert /myproject
    RewriteRule ^(.*)$ /public/myproject/$1


    ############################################################
    # Caching : Tell the web browser to cache images for 1 month
    <FilesMatch ".(flv|gif|jpg|jpeg|png|ico)$">
      Header set Cache-Control "max-age=2592000"
    </FilesMatch>


    ############################################################
    # Prevent Google from indexing your website
    # Another solution is to use a robot.txt file
    RewriteCond %{HTTP_USER_AGENT} AltaVista [OR]
    RewriteCond %{HTTP_USER_AGENT} Googlebot [OR]
    RewriteCond %{HTTP_USER_AGENT} msnbot [OR]
    RewriteCond %{HTTP_USER_AGENT} Slurp


    ############################################################
    # Set up Basic Authentication for your website
    # Do not forget to correctly fill .htpasswd
    #AuthName "My website"
    #AuthType Basic
    #AuthUserFile /SOMEDIR_OUTSIDE_ROOT/.htpasswd
    #require valid-user