Skip to main content

Posts

Showing posts with the label php

Code for Php based online Treasure Hunt

Hello guys. Some time back I organized an online treasure hunt as part of an event at my college. I thought of sharing the code with you, as you might find it useful. So, I uploaded it on github and here is the link to my repository. Download it from here , and enjoy organizing the game

PHP : Set document root to be a subdirectory without .htaccess or Virtualhost

Recently I faced a problem with hosting a website on a server to which I have limited access. I was provided with permission only to a sub-directory on the server. I'm habituated to use relative paths, but my root points to the root of server and not my sub-directory. This forced me to use absolute paths at every point. I searched for the solution and end up with two results: .htaccess ot Virtualhost I never tried to understand .htaccess and I don't have access to set Virtualhost . This forced me to try bit harder and here is the outcome. I've created a file named rootpath.php on root directory of my website. ( Note : this is not root '/' of the web server, but my sub-directory) Its contents are as follows: <?php     $relative_path = "/subdirectory";     $server_url = $_SERVER["SERVER_NAME"];     $root = "http://" . $server_url. $relative_path; ?> Now, I include this file on top of every file. Eg: <?php requi...