HTAccess:将子域重写为HTTPS主站点

时间:2014-10-29 15:15:25

标签: apache .htaccess ssl

我想将子域重写为主站点中的文件夹。

例如,test.example.com - > example.com/test

我只有example.com的SSL(CA验证)证书,但没有通配符证书。因此,test.example.com已加密但未经过验证。那么,是否可以将https://test.example.com重写为https://example.com/test,同时还可以保持验证?或者我应该只使用重定向?

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

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

1 个答案:

答案 0 :(得分: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

相关问题