.htaccess 子域重定向
我的服务器以某种方式配置为接受任何字符串作为现有的子域名。该子域不会重定向,而是显示内容。例如:
bla.example.com // 显示http://example.com
的内容
blabla.example.com // 显示http://example.com < strong>lorem.example.com/events/ // 显示http://example.com/events
所以你可以使用“stackoverflow.example.com”并且它会起作用。
我想创建一个 .htaccess 规则来覆盖此行为。我想将 http://*.example.com/* 重定向到 http://www.example.com/*
到目前为止我所做的一切都是将 http://example.com 重定向到 http://www.example.com (这是另一种行为我想保留)
RewriteCond %{HTTP_HOST} ^example\.com$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
谢谢你的帮助!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试将以下内容添加到域根文件夹中的 htaccess 文件中
Try adding the following to your htaccess file in the root folder of your domain