Reputation: 1437
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.
Upvotes: 3
Views: 3676
Reputation: 1
This worked well for me: RedirectMatch ^/subdomain(.*)$ https://subdomain.example.com
Upvotes: 0
Reputation: 277
htaccess:
RedirectMatch ^/subdomain/(.*)$ http://subdomain.mysite.com/$1
Upvotes: 2
Reputation: 1437
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]
Upvotes: 3