Nutic
Nutic

Reputation: 1437

Prevent access to folder of subdomain on main domain

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

Answers (3)

Girendra Persaud
Girendra Persaud

Reputation: 1

This worked well for me: RedirectMatch ^/subdomain(.*)$ https://subdomain.example.com

Upvotes: 0

Niv Asraf
Niv Asraf

Reputation: 277

htaccess:

RedirectMatch ^/subdomain/(.*)$ http://subdomain.mysite.com/$1

Upvotes: 2

Nutic
Nutic

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

Related Questions