htaccess:如果通过子域访问,如何将文件夹中的所有文件重定向到非子域?
使用 htaccess,如果在 /folder/myfiles/ 中访问文件,我需要删除 url 的子域部分,
例如。我需要重定向 sub.domain.com/folder/myfiles/anyfile.php 到 domain.com/folder/myfiles/anyfile.php
在 /folder/myfiles/ 中找到的任何文件如果通过子域访问,则必须重定向到根域上的同一文件。
背景:该网站在多站点上使用 WordPress 博客的子域。有一个第三方应用程序安装到根域上的文件夹中,许可证仅对根域有效,尝试通过子域访问它会使许可证无效,因此我需要确保该文件夹中的任何文件都必须是通过根域而不是子域访问。
using htaccess, I need to remove the subdomain part of the url if a file is accessed in /folder/myfiles/
eg. I need to redirect
sub.domain.com/folder/myfiles/anyfile.php
to
domain.com/folder/myfiles/anyfile.php
any file found in /folder/myfiles/ if accessed via a subdomain must be redirected to the same file on the root domain.
background: the site uses subdomains for wordpress blogs on multisite. There is a 3rd party app installed to a folder on the root domain, the licence is only valid for the root domain and attempting to access it via a subdomain invalidates the licence so I need to make sure that any file in that folder must only be accessed via the root domain and not a subdomain.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在文件夹的 .htaccess 中:
在根 .htaccess 或服务器配置中:
In the folder's .htaccess:
In the root .htaccess or server config: