简体   繁体   English

使用.htaccess将任何子域重写到目录

[英]Rewrite any subdomain to directory with .htaccess

Basically I want to make something like this: 基本上我想做这样的事情:

User enters in browser: https://user1.example.com/ (or any subdomain) 用户进入浏览器: https : //user1.example.com/ (或任何子域)

It shows the content of: https://example.com/user1 它显示以下内容: https : //example.com/user1

I searched the whole internet for a solution for this, but none work, it is always showing "We can't resolve the IP address of the server https://user1.example.com/ " and I could only figure out, that I have to use rewrite in .htaccess 我在整个互联网上搜索了解决方案,但是没有任何结果,它始终显示“我们无法解析服务器的IP地址https://user1.example.com/ ”,我只能弄清楚,我必须在.htaccess中使用重写

RewriteCond %{HTTP_HOST} ^(.*)\.example\.com
RewriteRule ^(.*)$ https://example.com/%1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM