限制访问 Web 目录但允许子域
我试图拒绝直接访问的人对子域目录的访问,而不是让他们直接浏览子域。例如,我希望人们能够访问 http://test.example.com 而不是 http://example.com/test。如果它们确实显示 403 Forbidden 错误。这可以通过 htaccess 实现吗?谷歌搜索但看不到有人这样做。主要目的是禁止他们直接访问内容。尝试了以下方法没有成功。
<Directory /test>
Order Deny,Allow
Deny from all
Allow from .example.com
</Directory>
I am trying to deny access to a sub-domain directory from people accessing directly rather get them to browse to the sub-domain directly. For e.g I want people to be able to go to http://test.example.com and not http://example.com/test. If they do show a 403 Forbidden error. Is this possible through htaccess ? Googled it but cant see anyone doing this. The main purpose being to disallow them from accessing the contents directly. Tried the following to no success.
<Directory /test>
Order Deny,Allow
Deny from all
Allow from .example.com
</Directory>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以执行从
example.com/test/
到test.example.com
的永久重定向。这将确保每个人都可以访问test.example.com
下的网站。这将更适合您的用户。如果你真的想显示 403 Forbidden,你可以这样做
You can do a permanant redirection from
example.com/test/
totest.example.com
. This will make sure everyone visit your site undertest.example.com
. This would be more appropriate for your users.If you really want to show a 403 Forbidden, you can do this