2014-10-29 123 views
0

我想重写一个子域到我的主站点中的文件夹。HTAccess:重写子域到HTTPS主站点

例如,test.example.comexample.com/test

我只有example.com的SSL(CA验证)证书,但不是通配符证书。因此,test.example.com已加密但未验证。那么,是否有可能重写https://test.example.comhttps://example.com/test,同时还要维护验证?或者我应该只使用重定向?

目前,这是我的文件夹结构:

.htaccess 
public_html/ # this is the document root for example.com 
    ... 
test/ # document root for test.example.com 
    ... 
+0

但是'test.example.com'应该已经从'/ test /'文件夹加载内容不是吗? – anubhava 2014-10-29 15:36:19

+0

那么,我的主要目标是允许我的一个SSL证书(这是我的主域名)在子域上工作。 – 2014-10-29 16:59:19

回答

0

将这个规则在/test/.htaccess

RewriteEngine On 

RewriteCond %{HTTP_HOST} ^(test)\.(example\.com)$ [NC] 
RewriteRule^http://%1/%2%{REQUEST_URI} [L,NE,R=302] 

这将重定向test.example.com --> example.com/test