Personally when I install a CMS I prefer to set it inside a subdirectory rather than the root folder.
There are different reasons for this choice. For example you may wish to have different CMS installed in different subdirectories; or multiple copies or versions of Processwire in different subdirectories; keep separated directories for production and development; and so on. Sometimes this choice is taken also to obfuscate your CMS contents.
In this forum I found some helpful hints, but I could not find a turn-key tutorial explaining the detailed steps for redirection and how to hide subfolder in urls' segments.
It's pretty easy. Just let's do it step by step.
We are going to create a new .htaccess file in the root folder (please note it is a new one, we will leave the .htaccess file in Processwire subfolder unchanged), where we will add the section described below. Just replace yoursite.com and yoursubfolder with ... your ones!
# .htaccess in root directory
# Redirect to Processwire subdirectory
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www.)?yoursite.com$
RewriteCond %{REQUEST_URI} !^/yoursubfolder/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /yoursubfolder/$1
RewriteCond %{HTTP_HOST} ^(www.)?yoursite.com$
RewriteRule ^(/)?$ yoursubfolder/index.php [L]
</IfModule>
With this approach we can protect root files and subdirectories from redirection.
Are we done ? Yes and no. After these modifications pages are redirected correctly, but in the browser link you will note that subfolder's name is still showing. This is not good, we want to hide it.
We are just one step away. Let's open our site/config.php and add the following line at the end:
/**
* Set urls root to hide Processwire folder
* This must be combined with .htaccess in root directory
*/
$config->urls->root = '/';
Do not forget to lock site/config.php after modifying it.
If you prefer, instead of modifying config.php, you can place the above line in _init.php.
And here it is! I hope this simple tutorial can be of help.