Disable access to addon domain via main domain

2019-08-09 04:37发布

I have like 10 addon domains on my main website, and atm you can visit any addon (call it test1.com) website with link as test1.mainwebsite.com or www.mainwebsite.com/test1

How can I block this access to addons?

I have tried this, but this block only www.mainwebsite.com/test1 way.

   RewriteEngine On
    RewriteCond %{HTTP_HOST} ^(www.)?mainwebsite.com$ [NC]
    RewriteCond %{REQUEST_URI} ^/google.com/(.*)$ [OR]
    RewriteCond %{REQUEST_URI} ^/something.net/(.*)$ 
    RewriteRule ^(.*)$ - [L,R=404]

1条回答
一夜七次
2楼-- · 2019-08-09 05:04

Disable access to a subdomain

The following is an example '.htaccess' code which provides a thorough means of making the Addon domain folders, and their contents, invisible through the main domain by forcing a "404 Not Found" error. This will work both for web browsers and search engines:

RewriteEngine On
        RewriteCond %{HTTP_HOST} ^(www.)?domain.com$ [NC]
        RewriteCond %{REQUEST_URI} ^/addonfolder/(.*)$
        RewriteRule ^(.*)$ - [L,R=404]
查看更多
登录 后发表回答