I read an article on my host on how to set a subfolder as the root of my domain, but it misled me into believing requests would all be sent to the /subfolder/ and not at all to the root, and that was not the case.
I'm using this code in .htaccess in the root and unfortunately, it's not working as desired.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?domain.com$
RewriteCond %{REQUEST_URI} !^/subfolder/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /subfolder/$1
RewriteCond %{HTTP_HOST} ^(www.)?domain.com$
RewriteRule ^(/)?$ subfolder/index.php [L]
What I'm trying to achieve is the following:
- Root in /subfolder/
- All requests to the original true root being denied as if it didn't exist at all. Such as phpinfo.php, php.ini, any page or miscellaneous item in there being denied access by the error handling set in the /subfolder/. Any request to "domain.com/whateverhere" absolutely always sent to /subfolder/.
- If possible, restrict any ability to go to domain.com/subfolder/ to show a 404. I suppose a redirect is equally effective though.
- I currently use a /resources/ folder in the root which is at domain.com/resources/ which contains scripts, css, images, etc. and even though the rewrite is in place to set the /subfolder/ to root, requests to domain.com/resources/ are still being accepted even though it's not in the /subfolder/. As I said before, I'd like to know how I can truly restrict any access to the true root, and force all requests to the /subfolder/.
All in all, I'd like the "root" to be completely set as the /subfolder/, have important files like phpinfo.php and php.ini in the actual root inaccessible, and still use .htaccess in the true root as usual.
I know I'm asking a lot here, so I apologize heh.
Thank you in advance to anyone who can assist.