具有.htaccess文件

时间:2018-08-12 04:36:41

标签: .htaccess mod-rewrite url-rewriting subdomain

我正在使用可通过2个域访问的Web服务器,例如exa_mple.com和example.com。假设exa_mple.com非常复杂,所以我想将来自exa_mple.com的所有流量重定向到example.com。另外,我想强迫他们使用https。到目前为止效果很好:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^exa_mple\.com [OR]
RewriteCond %{HTTP_HOST} ^example\.com [OR]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://www.example.com%{REQUEST_URI} [L]

现在,当我尝试打开http://www.exa_mple.com/testfile.html时,我实际上到达了https://www.example.com/testfile.html,这绝对是一个绝妙的选择。但是现在我的任务是确保它可以用于子域,例如。 testfile.exa_mple.com应该指向https://testfile.example.com,并且仍然指向正确的文件夹。

SSL适用于所有子文件夹,我只需要帮助找到正确的Rewrite-Conditions。 Allready尝试了很多事情,导致服务器错误或无法正常工作的重写条件。感谢您的帮助!

0 个答案:

没有答案