简体   繁体   中英

htaccess restrict from folder which is other domain?

I have issue which might be simple to solve with htaccess.

The main domain package is like www.domain.com and I have been adding new domains into my plan and those have been made as dns redirects to subfolders in that main domain package. What I have not realized is that anyone could access those new domains by entering www.domain.com/otherdomain

The hosting company says that those should have been ordered to be place one level higher but I did not know that. Is there way to restrict that IF someone accidentally finds or tests the example, that "otherdomain" would not allow redirects from www.domain.com? or what is the right way?

You will need to places rule as first rule in the otherdomain/.htaccess file:

RewriteEngine On

# if hostname in request is domain.com
RewriteCond %{HTTP_HOST} domian\.com$
# return forbidden error
RewriteRule ^ - [F]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM