Redirect subdomain request to subdirectory + https (using .htaccess)

最后都变了- 提交于 2019-12-06 11:01:20

Try this rule:

RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(specific|list|of|subdomains)\.example\.com$
RewriteRule ^ http://www.example.com/%1%{REQUEST_URI}

If you use mod-rewrite, it will appear to the user that they are using subdomain.domain.com while the actual files are being served by the webserver out of www.domain.com/subdomain. unfortunately, the webserver will be sending the ssl certificate for www.domain.com, leading to a domain mismatch and causing the user's browser to complain. there is nothing you can do about this.

one option is to come clean to your users and simply redirect them to www.domain.com/subdomain instead of rewriting their requests. you can use the apache Redirect directive to do this, or you can just send a Location: header back from a placeholder html file.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!