停止使用htaccess访问我的域 [英] Stop accessing my domain using htaccess

查看:27
本文介绍了停止使用htaccess访问我的域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有多个域托管帐户,因此我在其上托管了多个域.因此,我想将那些与主域分开.

I've multiple domain hosting account and so I've hosted multiple domains on that. So I want to separate those with the main domain.

Main hosting : https://example.com
Other hosted website : https://mydomain1.com, https://mydomain2.com

其他托管网站位于路径

https://example.com/domains/mydomain1
https://example.com/domains/mydomain2

因此任何人都可以使用上述路径访问其他域(如果他知道的话) 因此,要分隔所有我想要的域,如果有人使用该路径访问域,它应该显示错误消息,例如404或403

So anyone can access the other domain using the above mentioned paths(if he knows) So to separate all domains I want if anyone accessing the domains using the path it should display error message like 404 or 403

但是我不希望任何人使用这样的路径来访问,而是他/她可以使用实际的域名来访问.

But I don't want anyone to access using such path instead he/she can use the actual domain name to access.

任何建议表示赞赏.

PS:我在其他域中拥有htaccess文件,可将http请求重定向到https

PS: I've htaccess file in my other domain to redirect http request to https

RewriteCond %{HTTPS} off
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]

是否有其他方法可以同时实现这两个目标.重定向到https和以上查询.

Is there any other way to achieve both. redirection to https and above query.

谢谢

推荐答案

内部mydomain1/.htaccessmydomain2/.htaccess将此规则作为您的第一个规则:

Inside mydomain1/.htaccess and mydomain2/.htaccess have this rule as your very first rule:

RewriteEngine On

# show forbidden for main domain
RewriteCond %{HTTP_HOST} ^(?:www\.)?example\.com$ [NC]
RewriteRule ^ - [F]

这篇关于停止使用htaccess访问我的域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆