Thanks @Wanze .
So to make it clear, what I am doing is moving the index.php to a seprate folder.
Say
site
wire
web
index.php
So the problem we are going to face is none of the images, js, css cannot be accessed.
A good example is call for http://processwire.localhost/site/templates/styles/main.css will result in 404 , for the only entry point is index.php . I can create symbolic links, but I thought of making a module . So my goal is to create a module which can check whether the request is for a certain type ( css, image, js ) and return the content according to the type. (I have already created the same.)
About the usage of $_SERVER seems a bad idea to me as I mentioned earlier. If some ( 3rd party module ) replaces the content, hard to deal.
For those who don't know me, I have a bit of background in aura project ( and some other open-source projects ) and you can see the how the $_SERVER is accessed. Once you set, even if someone resets the superglobals the object value never changes.
Let me show you an example from aura v2
<?php
use Aura\Web\WebFactory;
$web_factory = new WebFactory($GLOBALS);
$request = $web_factory->newRequest();
echo " Request uri is " . $request->server->get('REQUEST_URI');
$_SERVER['REQUEST_URI'] = 'oye I am changing';
echo $_SERVER['REQUEST_URI'] . PHP_EOL;
echo $request_uri = $request->server->get('REQUEST_URI', '');
If you have tried the above example you will understand what I mean. ( I am not promoting aura here, my goal is to make PW things better and secure. I am also going to search for the thread composer and how it is utilized )
If anyone is interested have a look into the links below
https://github.com/auraphp/Aura.Web/blob/develop-2/README-REQUEST.md#superglobals
https://github.com/auraphp/Aura.Web/blob/develop-2/src/Request.php#L162
https://github.com/auraphp/Aura.Web/blob/develop-2/src/Request/Globals.php#L99
https://github.com/auraphp/Aura.Web/blob/develop-2/src/Request/Values.php#L36
Thank you.