I am re-writing a subdomain to some 'folder' - really a webpage in wordpress, which all appears to become working properly. I'm not going the address within the URL bar to alter though.

Everything works fine unless of course the consumer doesn't put a trailing slash following the page title, then your page continues to be rerouted towards the correct URL however the URL within the address bar changes

For instance: foo.example.com/bar Becomes: public.example.com/foo/bar

Where : foo.example.com/bar/ stays in the correct URL within the address bar but shows the rerouted page (this is)

What rule should i increase include a trailing slash if it is not sent?

The code i've to date is:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

Options +FollowSymlinks

RewriteCond %{HTTP_HOST} ^foo\.example\.com$ [NC]
RewriteRule ^(.*)$ http://public.example.com/foo/$1 [P]

# rules for WordPress ...

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

#####

</IfModule>

Any help could be fantastic, I am pretty a new comer to htaccess. Thanks!

This rule must do it:

RewriteRule .*[^/]$ %{REQUEST_URI}/

Put this rule before your other rules. Additionally you might want to give a condition to exclude existing files:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .*[^/]$ %{REQUEST_URI}/

Phew, after a little of experimenting i appear to possess first got it working:

RewriteCond %{HTTP_HOST} ^foo\.example\.com$ [NC]
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://foo.example.com/$1/ [L,R=301]

RewriteCond %{HTTP_HOST} ^foo\.example\.com$ [NC]
RewriteRule ^(.*)$ http://public.example.com/foo/$1 [P]

Essentially, the very first block adds a trailing slash towards the URL is it isn't there to begin with, then your second block does the proxy redirect for that URL.

So far as i can tell this catches every case, but tell me if you will find any gaping holes!