I have few websites on my host. Most of them have their own domain.
I want to prevent access to my subdomain folder via maindomain.com/subdomain .
I want to make it able to open only via subdomain.maindomain.com
Disable access if possible, or just redirect it to subdomain.
RewriteEngine on
RewriteBase /
#if not already blog.website.com
RewriteCond %{HTTP_HOST} !^blog\.website\.com$ [NC]
#if request is for blog/, go to blog.website.com
RewriteRule ^blog/$ http://blog.website.com [L,NC,R=301]