I've got a forum site that looks exactly like the main site. I want to keep users from browsing the forum site except for the forums and if they try to venture off the beaten path they are sent to the main site or possibly back to the forum site's main forum page.
Main site: example.com
Forum site: subdomain.example.com/forums/
I have a menu button on the main site (example.com) that when clicked, sends them to: subdomain.example.com/forums/
I've tried this in the subdomain's .htaccess and it doesn't seem to work. I've used something similar for use with an iframe, so I thought it might work in this situation. I tried incorporating the subdomain.example.com/forums/ into the mix, but I kept getting a redirect loop.
All this below does is redirect the user back to the main site when they click the forum menu button on the main site, so they can't access the forums. I believe I need some type of exception for the subdomain, but I've tried incorporating that as well and it didn't work either.
RewriteCond %{HTTP_REFERER} !^https?://(.+\.)?example\.com/ [NC]
RewriteRule .* http://example.com/$1 [R=301,L]
I've also experimenting using REQUEST_URI and got the same unwanted result.
Any suggestions/help would be greatly appreciated.