Changing the root folder via .htaccess
If I'm understanding correctly, the following should work
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/public/
RewriteRule ^(.*)$ /public/$1 [L,R=301]
This will redirect all requests that do not begin with /public/
to URL that does.
Hope that helps.
The DocumentRoot directive can't be set in a .htaccess file, only in the server config. As you most likely don't have the privileges to modify the server settings your only solution is to use some rewrite magic as clmarquart already mentioned.
This is how i always use it in my framework:
Rewritecond %{REQUEST_FILENAME} !-f
RewriteRule (.*) /example.com/public/$1 [L,NC]
RewriteCond %{REQUEST_URI} ^/$
RewriteRule !^example.com/public/(.*) /example.com/public/$1 [L,NC]
I use bluehost... this is what works for me: This is helpful when you are on shared hosting, and have multiple domain names.
Your primary domain is set to public_html but your add-on domains are subfolders inside public_html
This makes it so you don't have to have all your primary domain name files be mixed with add-on domain folders... each domain can be in their own folder...
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?PUTYOURDOMAINNAMEHERE.com$
RewriteCond %{REQUEST_URI} !^/PUTYOURFOLDERHERE/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /PUTYOURFOLDERHERE/$1
RewriteCond %{HTTP_HOST} ^(www.)?PUTYOURDOMAINNAMEHERE.com$
RewriteRule ^(/)?$ PUTYOURFOLDERHERE/ [L]
Options +SymLinksIfOwnerMatch